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

fix LibraryName of empty array #12828

Merged
merged 1 commit into from Mar 8, 2021

Conversation

chenxsan
Copy link
Member

@chenxsan chenxsan commented Mar 7, 2021

What kind of change does this PR introduce?

Right now it's possible to pass an empty array to output.library option:

module.exports = {
  output: {
    library: []
  }
};

And it outputs some weird results under development mode, see https://codesandbox.io/s/webpack-forked-6vvtk?file=/dist/main.js:

(undefined = typeof undefined === "undefined" ? {} : undefined) = webpack_exports;

And it throws error when running production mode:

webpack --mode production

assets by status 1.77 KiB [cached] 1 asset
runtime modules 670 bytes 3 modules
./src/index.js 37 bytes [built] [code generated]

ERROR in main.js from Terser
Invalid assignment [main.js:46,64]
    at js_error (/sandbox/node_modules/terser/dist/bundle.min.js:548:11)
    at croak (/sandbox/node_modules/terser/dist/bundle.min.js:1272:9)
    at maybe_assign (/sandbox/node_modules/terser/dist/bundle.min.js:3448:13)
    at expression (/sandbox/node_modules/terser/dist/bundle.min.js:3457:24)
    at simple_statement (/sandbox/node_modules/terser/dist/bundle.min.js:1581:55)
    at statement (/sandbox/node_modules/terser/dist/bundle.min.js:1406:24)
    at _embed_tokens_wrapper (/sandbox/node_modules/terser/dist/bundle.min.js:1337:26)
    at block_ (/sandbox/node_modules/terser/dist/bundle.min.js:2170:20)
    at _function_body (/sandbox/node_modules/terser/dist/bundle.min.js:2082:21)
    at arrow_function (/sandbox/node_modules/terser/dist/bundle.min.js:1690:20)

webpack 5.24.3 compiled with 1 error in 203 ms

I believe we should have at lease one value in the array passing to output.library.

Did you add tests for your changes?

No, since it's a schema change, test may not be needed?

Does this PR introduce a breaking change?

Nope.

What needs to be documented once your changes are merged?

Nothing.

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@sokra sokra merged commit 73af688 into webpack:master Mar 8, 2021
@sokra
Copy link
Member

sokra commented Mar 8, 2021

Thanks

@chenxsan chenxsan deleted the bugfix/fix-library-schema branch March 8, 2021 10:32
This was referenced Mar 8, 2021
This was referenced Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants