Skip to content

fix(webpack): set keep_quoted_props: true in TerserOptions #10382

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

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

rigor789
Copy link
Member

@rigor789 rigor789 commented Sep 14, 2023

PR Checklist

What is the current behavior?

In release builds, Terser strips quotes from props, and in some cases causes boot crashes while parsing the bundle/vendor chunks. For example, if the app uses a html-entities package, the mapping from entities -> their html equivalent causes the app to crash on boot in minified/production builds.

Example:

characters: {
    Æ: 'Æ',
    '&': '&',
    Á: 'Á',
    Ă: 'Ă',
    Â: 'Â',
    А: 'А',
    𝔄: '&Afr;', // <-- this fails
***** Fatal JavaScript exception - application has been terminated. *****
2023-09-13 22:14:29.640530-0700 app[1:1] NativeScript encountered a fatal error: Uncaught SyntaxError: Invalid or unexpected token
 at 
	require(:1:232)
	at __webpack_require__.f.require(file:///app/runtime.js:1:1468)
	at (file:///app/runtime.js:1:692)
	at __webpack_require__.e(file:///app/runtime.js:1:652)
	at __webpack_require__.X(file:///app/runtime.js:1:1143)
	at (file:///app/bundle.js:2:691934)
	at (file:///app/bundle.js:2:692118)
	at require(:1:232)

What is the new behavior?

The minified code will keep the original quotes from the library, example:

characters: {
    'Æ': '&AElig;',
    '&': '&amp;',
    'Á': '&Aacute;',
    'Ă': '&Abreve;',
    'Â': '&Acirc;',
    'А': '&Acy;',
    '𝔄': '&Afr;', // <-- this no longer fails

This can now properly be parsed and the app runs.

Fixes #9703, and likely also #8550.

@cla-bot cla-bot bot added the cla: yes label Sep 14, 2023
@rigor789 rigor789 merged commit 2cb26c2 into main Sep 14, 2023
@rigor789 rigor789 deleted the fix/webpack-terser-keep-quoted-props branch September 14, 2023 14:40
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 this pull request may close these issues.

Webpack 5 generating wrong output in bundle.js using --env.production
2 participants