check out my latest app: Doodle Draw
and my latest blog post
Dynamically add an asset to the Webpack graph
License: MIT License
check out my latest app: Doodle Draw
and my latest blog post
Is there a way to use the dynamically created file as a dependency of another module? E.g.:
Webpack config:
...
plugins: [
new AddAssetPlugin(
"file.js",
`export default {
a: 1,
b: 2,
c: 3
}
`
),
...
Then in src/myapp.js
:
import obj from 'file.js'
console.log(obj.a) // Outputs: 1
?
Webpack 5 complains quite loudly about this plugin:
(node:15826) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
at node_modules/add-asset-webpack-plugin/index.js:13:38
at Hook.eval [as callAsync] (eval at create (node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:17)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (node_modules/tapable/lib/Hook.js:18:14)
at Compiler.emitAssets (node_modules/webpack/lib/Compiler.js:763:19)
at node_modules/webpack/lib/Watching.js:80:21
at processTicksAndRejections (node:internal/process/task_queues:75:11)
When running webpack --watch
with incremental compilations and with a static string
type source
, the module will still add it on every incremental build which is useless and spams the log unneccesarily. Suggesting to emit a string
asset only once during --watch
. Function/Promise sources should of course be emitted every build because their content may change.
When running the tests I get:
⠹ (node:62443) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.