GithubHelp home page GithubHelp logo

sindresorhus / add-asset-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW
96.0 96.0 6.0 14 KB

Dynamically add an asset to the Webpack graph

License: MIT License

JavaScript 100.00%
javascript nodejs npm-package webpack webpack-plugin

add-asset-webpack-plugin's Issues

Webpack 5: DeprecationWarning: Compilation.assets will be frozen in future

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)

Only add once for --watch mode

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.

import and use dynamically created file in src/ code?

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

?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.