Webpack.js.org: Add docs on NamedChunksPlugin

Created on 25 Sep 2018  路  3Comments  路  Source: webpack/webpack.js.org

Feature to document

NamedChunksPlugin
https://github.com/webpack/webpack/pull/4553

Author(s)

@timse

Additional information

Didn't find any info on https://webpack.js.org/plugins/ (left hand side menu)

  • What problems does it solve?
  • Is it recommended? Deprecated?

It is recommended for long term caching (https://github.com/webpack/webpack/issues/1315#issuecomment-386267369) but it's not documented on the webpack website what the plugin does exactly and how (there's no info about its existence even ;))

    new webpack.NamedChunksPlugin(chunk => {
      if (chunk.name) {
        return chunk.name;
      }

      // eslint-disable-next-line no-underscore-dangle
      return [...chunk._modules]
        .map(m =>
          path.relative(
            m.context,
            m.userRequest.substring(0, m.userRequest.lastIndexOf("."))
          )
        )
        .join("_");
    }),

From quick check, AFAIU the goal is to have deterministic production code generated when using code splitting, like

  __webpack_require__.e("my-async-chunk-name").then(... // will stay the same

instead of

  __webpack_require__.e(7).then(... // this might change over time if new chunks are created
Plugins

Most helpful comment

I would like to second this issue. This really needs to be documented, especially since it is enabled by default with mode: 'development'. What exactly am I enabling?

https://webpack.js.org/concepts/mode/

All 3 comments

I would like to second this issue. This really needs to be documented, especially since it is enabled by default with mode: 'development'. What exactly am I enabling?

https://webpack.js.org/concepts/mode/

@sokra can you please shed some light so we can kick off a PR ? I dont really have time this week to go through the sources sorry :( Maybe someone else has time to dig into and file a PR please shout.

Was this page helpful?
0 / 5 - 0 ratings