Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack v5: missing dynamic chunks generated by splitChunks when chunk IDs are strings #104

Open
OliverJAsh opened this issue Oct 8, 2021 · 0 comments · May be fixed by #105
Open

webpack v5: missing dynamic chunks generated by splitChunks when chunk IDs are strings #104

OliverJAsh opened this issue Oct 8, 2021 · 0 comments · May be fixed by #105

Comments

@OliverJAsh
Copy link

Full reduced test case: https://github.com/OliverJAsh/webpack-flush-chunks-webpack-v5-bug

package.json:

{
  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "webpack": "^5.58.0",
    "webpack-cli": "^4.9.0",
    "webpack-flush-chunks": "^2.0.3"
  }
}

webpack.config.js:

module.exports = {
    mode: "production",
    entry: "./src/entry.js",
    optimization: {
        chunkIds: 'named',
    }
};

src/entry.js:

import(/* webpackChunkName: "routeA" */ './routeA')
import(/* webpackChunkName: "routeB" */ './routeB')

src/routeA.js:

import React from 'react';
import ReactDOM from 'react-dom';
React;
ReactDOM;

src/routeB.js:

import React from 'react';
import ReactDOM from 'react-dom';
React;
ReactDOM;

test.js:

const flushChunks = require("webpack-flush-chunks").default;

const stats = require("./stats.json");

const result = flushChunks(stats, { chunkNames: ["routeA"] });

console.log(result.scripts);

Run these commands:

rm -rf dist
webpack --json=stats.json
node test.js

Expected result:

[ 'routeA.js', 'main.js' ]

Actual result:

[
  'vendors-node_modules_react-dom_index_js.js',
  'routeA.js',
  'main.js'
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant