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

Shared entry fails with configureFilenames #618

Closed
XWB opened this issue Jul 23, 2019 · 1 comment · Fixed by #619
Closed

Shared entry fails with configureFilenames #618

XWB opened this issue Jul 23, 2019 · 1 comment · Fixed by #619
Labels

Comments

@XWB
Copy link
Contributor

XWB commented Jul 23, 2019

In extend to #615

Imagine the following configuration:

Encore
    .createSharedEntry('js/functions, './assets/js/functions.js')
    .addEntry('js/js1', './assets/js/js1.js')
    .addEntry('js/js2', './assets/js/js2.js')
    .enableVersioning(Encore.isProduction())
    .configureFilenames({
        js: '[name].js?[contenthash:8]',
        css: '[name].css?[contenthash:8]'
    });
;

Now when I run yarn encore dev, the command fails with the following error:

Error: Invalid number of files for chunk js/functions - got
    at getChunkFilename (node_modules/@symfony/webpack-encore/lib/webpack/shared-entry-concat-plugin.js:33:15)
    at ....

Error Command failed with exit code 1.

When I remove configureFilenames, everything works as expected. Any idea how I should resolve this?

Note: I use dynamic imports.

@Lyrkan
Copy link
Collaborator

Lyrkan commented Jul 23, 2019

Hi @XWB,

Thanks for the report I can reproduce the issue on my end (without dynamic imports).

I suspect that the following check wrongly removes a file from jsFiles because it ends by .js?xxxxx instead of .js:

const jsFiles = chunk.files.filter(filename => {
return /\.js$/.test(filename) && !additionalChunkAssets.includes(filename);
});

@Lyrkan Lyrkan added the Bug Bug Fix label Jul 23, 2019
@Lyrkan Lyrkan added the HasPR label Jul 23, 2019
weaverryan added a commit that referenced this issue Aug 9, 2019
…g strategy (Lyrkan)

This PR was merged into the master branch.

Discussion
----------

Fix createSharedEntry(...) when using query string versioning strategy

This PR fixes #618 by correctly filtering the JS files of the shared entry (in the `SharedEntryConcatPlugin`) when versioning is handled in a query string.

Commits
-------

0f63369 Fix createSharedEntry(...) when using query string versioning strategy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants