faceyspacey / faceyspacey/webpack-flush-chunks

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

Open
#104 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
354
Forks
30
PR merge metrics
No merged PRs in 30d

Description

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

`package.json`:
```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`:
```js
module.exports = {
mode: "production",
entry: "./src/entry.js",
optimization: {
chunkIds: 'named',
}
};

```

`src/entry.js`:
```js
import(/* webpackChunkName: "routeA" */ './routeA')
import(/* webpackChunkName: "routeB" */ './routeB')
```

`src/routeA.js`:
```js
import React from 'react';
import ReactDOM from 'react-dom';
React;
ReactDOM;

```

`src/routeB.js`:
```js
import React from 'react';
import ReactDOM from 'react-dom';
React;
ReactDOM;

```

`test.js`:
```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:

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

Expected result:

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

Actual result:

```js
[
'vendors-node_modules_react-dom_index_js.js',
'routeA.js',
'main.js'
]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.