Comments (11)
@jpbriggs408 There is a fix #18152, I decide to avoid proxy check, because it is not universal (we can't undestand when it is a plain object or a proxied object, except node.js utils ), so let's just keep unsafeCache as is and avoid the object creation
from webpack.
I see your problem
from webpack.
I found two solution:
- in
convertToResolveOptions
:
const unsafeCache = options.unsafeCache;
const normalizedOptions = removeOperations(
resolveByProperty(options, "byDependency", dependencyType)
);
if (unsafeCache !== undefined) {
normalizedOptions.unsafeCache = unsafeCache;
}
return normalizedOptions;
This is not a universal solution, we assume that only there a proxy can be used for unsafeCache
-
Implement
const removeOperations = (obj, ignoredKeys = []) => { /* ... */ }
and so putunsafeCache
inignoredKeys
, so keep them as is without deep merging, like the1.
but just improving -
Make
Proxy
to beVALUE_TYPE_ATOM
ingetValueType
, but it is only for Node.js, so if somebody will want to bundle webpack for browser, it will not work
const getValueType = value => {
if (value === undefined) {
return VALUE_TYPE_UNDEFINED;
} else if (value === DELETE) {
return VALUE_TYPE_DELETE;
} else if (util.types.isProxy(value)) {
return VALUE_TYPE_ATOM;
} else if (Array.isArray(value)) {
if (value.lastIndexOf("...") !== -1) return VALUE_TYPE_ARRAY_EXTEND;
return VALUE_TYPE_ATOM;
} else if (
typeof value === "object" &&
value !== null &&
(!value.constructor || value.constructor === Object)
) {
return VALUE_TYPE_OBJECT;
}
return VALUE_TYPE_ATOM;
};
All solutions works with your repo. But yeah, that is intresting problem, because we use getValueType
in many places, and so these places will not work with Proxy
Want to get some feedback from you
from webpack.
Another solution like 3.
but we can make it smarty:
if (util.types.isProxy(value) || value.__isProxy) {
}
and
fileSystemAwareCache.__isProxy = true;
so it give ability to mark Proxy in a browser
from webpack.
Thank you for the quick response!
Options 1 and 2 seem like the safest immediate fixes with minimal impact, though we acknowledge they might not cover all future scenarios.
Option 3 (and its browser-compatible variant) do offer a more universal fix. It does seem like the most ideal solution to our specific problem. However, our main concern revolves around potential side-effects across other getValueType
usages. It would be great to know more about the specific operations removeOperations
aims to exclude from your perspective. That would help us to gauge this option's viability better. That being said, we only pass in our custom cache object in the development environment, but browser compatibility is important to us.
from webpack.
see if this helps
const fileSystemAwareCache = new Proxy({}, {
get(target, key, receiver) {
if (key in target) {
const entry = target[key];
if (entry && fs.existsSync(entry.path)) {
return entry;
} else {
delete target[key];
}
}
return undefined;
},
set(target, key, value, receiver) {
target[key] = value;
return true;
}
});
from webpack.
@alexander-akait thank you so much! I think this solution makes a lot of sense.
If documentation needs to be updated, I'm happy to take a crack at it. Let me know, and thanks again!
from webpack.
I don't thank we need document it, because it is like a bug
from webpack.
Totally reasonable! In webpack's documentation, it isn't clear that an object can be passed, but that is outlined in enhanced-resolve
's code which is sufficient enough to me.
from webpack.
@alexander-akait thank you for this fix, we really appreciate it! Would we be able to get a release cut with this fix in it at your convenience?
from webpack.
Yeah, this week
from webpack.
Related Issues (20)
- Implement ability to use "node:" prefixes for Node.js core modules HOT 1
- mangled exports breaks with destructuring assignment of JSON imports HOT 7
- there are confusing JDocs code
- Potential bug issues
- Webpack is not resolving node_modules specified in `resolve.modules` property.
- Dynamically loading chunks
- [Code implementation issues] ArrayQueue
- [feature] create cli HOT 3
- Not able to build node script
- bootstrap:27 Uncaught TypeError: __webpack_require__.nmd is not a function
- Self-reference dependency has unused export name when imported inside of a web worker
- support `import.meta.dirname` and `import.meta.filename` HOT 2
- <!-- identifier: admin-actions -->
- Remote into Web Component from React giving an error saying " Module does not exist in container"
- Multiple DefinePlugin instances cause aggressive cache invalidation due to collisions HOT 7
- import .scss build to js, the exported mapping is inconsistent with the usage【Urgent!!】
- Unused code elimination and deduplication is not applied when using sass's api: 'legacy' setting
- In cli, why no option named "--output-file-name" ?
- Need help with migrating a custom middleware from v3 to v5 of webpack-dev-server
- Module federation: the usage of "dynamic remotes" will cause blank screen when working with `runtimeChunk`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack.