Silind-Software / direflow

🧩 Use the best of two worlds. Create fast, performant, native Web Components using React.
https://direflow.io
MIT License
501 stars 78 forks source link

`File sizes after gzip` fails when using a token for 'chunkfileName' #251

Closed tspringborg closed 3 years ago

tspringborg commented 3 years ago

Describe the bug
After including a npm package with some webcomponents built by stenciljs my direflow build failed with:

Conflict: Multiple assets emit to the same filename vendor.js

Fixed this by modifying the filechunkName in the webpack config to use a token instead.

const { webpackConfig } = require('direflow-scripts');
module.exports = (config, env) => ({
    ...webpackConfig(config, env),
    output: {
        ...webpackConfig(config, env).output,
        chunkFilename: "[name].js", // this fixed the chunks issue. Default in direflow is vendor.js
    }
})

Now running direflow-scripts build correctly creates a direflowBundle.js file in which everything seems in order.

But the build "fails" when trying to report filesizes

...

Filesizes after gzip:

ENOENT: no such file or directory, open ******\demo-direflow\build\3.js

....

To reproduce

I've created a repo that can reproduce the issue. https://github.com/tspringborg/direflow-chunks-issue

Which is a default direflow create with https://github.com/telekom/scale installed and imported

Note The filename reported missing in the demo repo is not 3.js since I'm using another, publically available, stenciljs built library in the demo repo.

Expected behavior
Shouldn't exit with an error.

Package Manager:
To install Direflow, I used npm

node version:v12.13.1 npm version: 8.1.3 OS: macOS 10.15.7 (Catalina)

martianatwork commented 3 years ago

Fixed it by using


module.exports = (config, env) => {
  const wc = webpackConfig(config, env);
  wc.plugins.push(new webpack.optimize.LimitChunkCountPlugin({maxChunks: 1}))
  return wc
}
tspringborg commented 3 years ago

Thank you @martianatwork. This also solved it for us.