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

Unexpected token: punc (.) #1921

Open
ksolanki9 opened this issue Sep 18, 2023 · 6 comments
Open

Unexpected token: punc (.) #1921

ksolanki9 opened this issue Sep 18, 2023 · 6 comments

Comments

@ksolanki9
Copy link

ksolanki9 commented Sep 18, 2023

🐛 Bug report

Current Behavior

Terser is creating issue while minification when minimizing one third part module on local machine.

Unexpected token: punc (.) [webpack://javascript/esm|./node_modules/somethirdpartypackage/dist/components/folder1/file1.js:24,0]
at ne (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:195)
at c (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:282)
at l (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:283)
at f (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:284)
at U (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:422)
at me (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:483)
at c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:492
at ve (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:492)
at ke (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:504)
at We (c:\temp\node_modules\terser-webpack-plugin\node_modules\terser\dist\bundle.min.js:1:507)

If we put minimization off as mentioned here #1012 then it works but then for whole project js compression and minimization not happening. do you know any workaround or exclude some particular node_modules from minification then would be good.

Your environment

Software Version(s)
Razzle 4.2.18
Razzle Plugins 4.2.18
Node 18
Browser NA
npm/Yarn yarn
Operating System windows
TypeScript >5.0
React 18.2
@bassamIHabash
Copy link

bassamIHabash commented Sep 20, 2023

Does your issue solve with React 18.2.0 ? @ksolanki9

@ColinFendrick
Copy link

I'm also running into a similar issue. Optional chaining works fine in my code but razzle isn't compiling node modules correctly. Any time I install a node module with optional chaining the terser build breaks with Unexpected token: punc (.) . This is preventing me from installing many packages. Is there a way to just update razzle/terser's compilation target?

@ColinFendrick
Copy link

Update on this, setting webpackConfig.optimization.minimize = false fixes this but also triples the bundle size. Is this really the workaround?

@ksolanki9
Copy link
Author

below config fixed my issue, try once
webpackConfig.optimization = {
minimize: true,
splitChunks: {
chunks: 'all'
}
}

@ColinFendrick
Copy link

Thank you, this works! It works because we removed the plugins from the webpack optimization minimizer though. Did you have any issues with bundle size or unminimized css?

@ColinFendrick
Copy link

So an update on this, this caused an error in production: Unexpected token '<'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants