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)
- Module Federation - Some chunks are not loaded when navigating from the Remote module to the Host module
- failed to import ffmpeg-core.js HOT 1
- Webpack 5 doesnt generate the chunks of imports HOT 1
- Error: Cannot find module 'webpack-cli/package.json' HOT 2
- Unable to bust cache of module federation remotes....
- Re-exported Ant Design components don't have same style with the original components
- failed to import ffmpeg-core.js HOT 3
- DllPlugin: When processing multiple chunks, does the `path` option must have a string template?
- Webpack BannerPlugin with `raw` option should put `use strict` on the very first line HOT 10
- After webpack 5 migration not able to use local packages in a mono repo
- 95% emitting emit phase takes much longer in Node >=16
- Plugin apply not working for multi compiler HOT 2
- packages/tailwindcss/src/compile.ts HOT 1
- Current error handling mainly involves calling the `onInvalidCandidate` callback function to handle invalid candidates, and printing corresponding error messages to the console.
- [5.91.0] "Fixed fs types" breaks `outputFileSystem` compatibility with `memfs` HOT 8
- Using `[name]` within `output.library`, the correct value isn't utilized in the source map namespace HOT 3
- Not found node_modules/@angular/common/bundles/common-http.umd.js
- webpack5.90.0 Modifying files in the node_modules directory (local component library) cannot trigger hot updates HOT 1
- Delete this.
- how to make webpack recompile on dev mode with cache on?
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.