Questions tagged [terser]
Terser is a JavaScript parser and mangler/compressor toolkit for ES6+ (ECMAScript 6+ / JavaScript 6+)
112
questions
0
votes
0
answers
19
views
Terser eror Unexpected token: punc (}) [.js/1.chunk.js:3596,78] at ee (C:\..) in webpack when creating a react typescript productin build with aws-sdk
I'm trying to integrate cognito-identity-js and aws-sdk in my react typescript project. While I'm using aws-sdk module and trying to create build, I'm getting the following error
ERROR in .js/1....
0
votes
0
answers
7
views
minify heroku slugs on build terser
I recently used "heroku run" and looked around inside my package.json nodejs app, the slug is NOT minified in /node_modules . I am using the standard "heroku/nodejs" buildpack. ...
0
votes
0
answers
13
views
How to remove console.log of dependency modules using Rollup, Except my codes
I want to remove console.log of dependency modules (node_modules).
So I tried terser({ compress: { drop_console: true } }).
But, It drops even console.log of my codes.
I want to remove console.log of ...
1
vote
0
answers
18
views
Terser: Annotate function as always pure (and what does it mean)
To assist with optimization Terser supports the pure comment to indicate that a function call is pure. Specifically, the docs give only the following example.
const x = /*#__PURE__*/...
0
votes
0
answers
19
views
Webpack optimization | Terser plugin not reflecting any change in bundle size
I am using Terser plugin to minify the bundle size in production mode, but I am not able to see any change in bundle size.
Is this because Terser plugin is automatically applied in production mode? I ...
2
votes
1
answer
174
views
Typescript const enum alternative
More and more modern Typescript transpilers have moved toward a strategy of per-module transpilation, which significantly increases build speed, but eliminates the possibility for cross-module const ...
0
votes
0
answers
17
views
How to debug terser mangle properties keep quoted true rendering webgl of black screen
I have this terser plugin in rollup:
const { terser } = require('rollup-plugin-terser')
plugins = [terser()]
if I pass this options:
plugins = [terser({ mangle: { properties: { keep_quoted: true } } ...
3
votes
1
answer
308
views
How to resolve "Parcel build failed. @parcel/optimizer-terser: "_" is redeclared" error
Good day everyone!
When I tried to build my parcel-based app, I encountered the following error:
Build failed.
@parcel/optimizer-terser: "_" is redeclared
3724 |
> 3725 | let _ = (t1)=...
0
votes
0
answers
98
views
Create react app failing to build on aws amplify
I am trying to deploy my react application to aws amplify. the app works fine locally and on netlify(used for staging).
I am seeing error in the build logs which is attached below.
I actually do not ...
0
votes
1
answer
156
views
My Razzle Terser build is broken ''Unexpected token: punc (.)'
I have a Razzle app and build is broken. It doesn't make sense as the error shown in build result points to something that doesn't exist in my code. This is the error message from Terser:
'Unexpected ...
0
votes
0
answers
15
views
Webpack Compression Affecting Map Key
I need webpack compression for my project in production mode. However, during compression, there is a Map whose keys get changed to short representation. Later when I try to get an item using the ...
1
vote
0
answers
125
views
Minifying a CSS file using terser
I have had some success minifying a .js file using terser. However, I have so far not been able to minify a standalone CSS file, and this is the reason for this qestion. I have installed html-minifier-...
0
votes
0
answers
208
views
Angular ERROR in polyfills-es5.js from Terser
While trying to upgrade from angular 8 to 9, I get following error when trying to run ng build --prod.
Error in detail:
ERROR in polyfills-es5.js from Terser
Invalid assignment [polyfills-es5.js:1,17]
...
2
votes
1
answer
80
views
Terser keep (don't mangle) a specific function name
Is there a way to not mangle only one function name? A comment in the code would be easiest, but I guess this could be done by specifying a custom "nameCache" ? But I don't know how that ...
0
votes
0
answers
23
views
Tree-shaking development builds with webpack
I have a dependency that includes references to document that gets imported into a service worker. The documents are tree-shaken out in production mode. However, I actually need for my service worker ...
0
votes
0
answers
14
views
Webpack: Modify source before generating source maps
I'm using Webpack 4, SourceMapDevToolPlugin and terser-webpack-plugin.
The problem is that I need to also modify the minified JS-bundles – inject specific code to the beginning of file. The mutation ...
0
votes
0
answers
117
views
Webpack @azure/storage-blob node-fetch AbortSignal issue
I am facing one particular issue often talked about at various places the link I will share later. The problem is related to the webpack bundling. My nodeJS application uses @azure/storage-blob ...
0
votes
1
answer
43
views
ng build --prod error after removing the bootstrap
I am using angular11 and after removing the bootstrap from my project it gives below error when run command ng build --prod
Earlier it is working fine. i tried to update core and terser depenadicies ...
1
vote
1
answer
98
views
How do I register a compressor with sprockets on the command line?
I want to use Sprockets at the command line (with the ruby-sprockets Debian package), and I want to use Terser as the JavaScript compressor (because Uglify doesn't support ES6). All the documentation ...
0
votes
0
answers
23
views
How to disable showing webpack:// directory in browser devtool with webpack4?
Even if you use terser or tools like javascript obfuscator, you can still see 'webpack://' directory and source code in browser devtool.
Is there any way to disable showing 'webpack://' directory so ...
0
votes
0
answers
20
views
terser Webpack plugin margle unwanted props
I am using treser webpack plugin with :
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
top_level: true,
mangle: {
//properties: true
...
2
votes
0
answers
262
views
Keep some comments in Webpack 5 production javascript output
I think I'm going insane, because every search engine throws me only results on how to remove the comments from output file and that's completely opposite of what I searched for 😤
I use all defaults ...
1
vote
1
answer
139
views
Terser: prefix all mangled variables and functions
I'm working on a single-file script that is meant to be included on pages through a <script> tag, it's being built with Vite.js using the Terser minifier.
After making changes I noticed that the ...
1
vote
0
answers
93
views
How to retrieve the nameCache from minify-html minifyJs (UglifyJS / Terser) after a Gulp task stream pipeline
I am using the Terser fork of UglifyJS inside the Gulp wrapper of html-minify and want to persist and restore the minifyJS nameCache.
The underlying Terser library explains how to do it here but that ...
0
votes
2
answers
625
views
Laravel mix, webpack, terser - strip console log in production bundle
I'm trying to strip console log and console debugs from the production build of my laravel + react app. I found many different solutions but none seemed suitable for my environment.
I'm still trying ...
0
votes
1
answer
163
views
ERROR while ng build --prod "Cannot negate a statement"
I am using following command to build angular project (it has some bower components under assets folder):
./node_modules/.bin/ng build --prod --base-href /project
And after running above command I ...
0
votes
0
answers
79
views
How to investigate vague "js/chunk-venders... from Terser" undefined failure?
My Vue-CLI project is failing to create a production build:
⠏ Building for production...
ERROR Failed to compile with 1 errors ...
0
votes
1
answer
225
views
dotenv-webpack and terser: error from Terser Invalid assignment
I'm working on an electron application. I've added the dotenv-webpack plugin in webpack config, but when I try to build it, I receive an error from Terser. Furthermore, if I comment on the ...
0
votes
1
answer
502
views
How do I get sourcemaps my original TypeScript code using rollup and terser?
A similar question was asked here: Rollup is not generating typescript sourcemap
..but about rollup with svelte for minification (with which I'm not familiar) rather than terser. I'm not sure how much ...
3
votes
1
answer
675
views
Scoping issue with terser-webpack-plugin options
I have a situation where I don't have Terser configured correctly and it's causing the compressed version of my page to break. My issue is that I have some functional declarations in my index.js. ...
0
votes
0
answers
166
views
Remove vendors comments in Angular build without using optimisation
I have a Angular library project which I use in my main Angular project (the library is hosted in my private npm registry).
When I use my library in my main project, I must have access to his comments ...
0
votes
0
answers
63
views
Angular 11 Exclude Unused Classes
I'm trying to compile a large Angular 11 web application. This application has some files that are code generated.
Here is an example...
File:
models.ts
Contents:
export class A {
... // No ...
0
votes
0
answers
184
views
How can webpack terser avoid mangling jQuery methods?
When using webpack 5 with Terser mangle options. We must keep mangling enabled in production for business reasons on this project.
optimization: {
minimize: true,
minimizer: [
...
1
vote
1
answer
126
views
Why does Terser Webpack plugin generate different file names in development and production modes?
I have recently upgraded to Webpack 5, and had to drop Uglify in favour of the Terser plugin.
However now when I build my project I get different output files when I'm in different modes.
// mode: '...
1
vote
0
answers
171
views
Gulp build results in webpack error with terser: Unexpected token: punc (:)
Here's the error log for reference:
[00:13:30] [Webpack errors]:
[00:13:30] activity-sidebar.js from Terser
Unexpected token: punc (:) [webpack://./node_modules/box-ui-elements/node_modules/...
2
votes
1
answer
93
views
How to pass terser options to html-minifier-terser
How to pass terser options to html-minifier-terser (https://www.npmjs.com/package/html-minifier-terser)?
The docs do not show any way to send it, only general options for html minify processing.
4
votes
1
answer
683
views
Can Webpack tree-shake to remove imports already removed by tree-shaking
Can Webpack be configured so that its tree-shaking is smart enough to remove imports depended on by only other tree-shaken exports?
Example:
entry.js
import { apple } from './appleBanana';
console.log(...
0
votes
1
answer
208
views
Keep `terser` from changing function argument names
Let's say there's a function
function fname (arg1) {}
When terser minifies it, it changes both the function name and the argument names (by deafault)
I need to keep the argument name as is.
I've ...
0
votes
1
answer
98
views
Forge Viewer property database userFunction not found due to Vue webpack mangling (terser)
I am using a userFunction to query the property database in a custom Forge Viewer extension. This works great while testing the site locally using npm run serve. However, when I deploy the website to ...
1
vote
0
answers
441
views
How to use `keep_classnames` properly?
I updated Angular in old app (from 7 to 11), everything went fine except for one thing :). At the outset, let me say that I'm not an expert in Angular.
After executing command ng build --prod, I got:
...
2
votes
0
answers
134
views
Source map in grunt (babel + terser)
I`m using babel & terser in grunt. Both of them generate sourceMaps.
Babel has to be executed first, so it's sourceMap should be an inputSoruceMap for terser.
I've found something similar on ...
0
votes
0
answers
27
views
Any babel plugin to remove unnecessary assignment?
I am trying to optimize my bundle and I want to transform code from this:
const tmp = '1'
obj['a'] = tmp
str += tmp
to this:
let str = ''
const obj = {}
str += obj['a'] = '1'
Is there ...
0
votes
1
answer
298
views
Execute multiple terser commands (compression/mangling) inside a .bat file
Terser is a free tool for compressing and/or mangling javascript files.
As far as I have understood, the tool relies on node.js, so that is a pre-req for running Terser in the first place.
This will ...
6
votes
1
answer
10k
views
UglifyJS and webpack v5
We've been using UglifyJS and webpack v4 for our react code, but then just updated to webpack v5. It appears that UglifyJS does not work with webpack v5. Is there an alternative? We need something ...
0
votes
0
answers
254
views
SyntaxError: Unexpected token: eof (undefined) when concatenating file contents with string then minifying with terser
I'm trying to read a file and save the file contents to a variable. I then want to use that variable and concatenate to it and parse it in other ways then minify it using terser but I keep getting an ...
2
votes
0
answers
165
views
How to resolve " Unexpected character '#' " using gulp-terser to minify files
I'm using this code to minify all my js files of a project in one file:
var gulp = require('gulp');
var terser = require('gulp-terser');
var gp_concat = require('gulp-concat');
const { dest } = ...
23
votes
1
answer
8k
views
TypeError: Cannot read property 'javascript' of undefined + terser webpack plugin + react js
I recently added terser-webpack-plugin to minify my create react app code. But while build the project I got an error like TypeError: Cannot read property 'javascript' of undefined. Below are some ...
0
votes
1
answer
90
views
preserve json object used as dictionary with terser
I currently bundle my typescript code with rollup and want to use terser for minifying/uglifying. In my code I have a dictionary object and imported it into my typescript code.
const dict = { ...
0
votes
1
answer
1k
views
Support old browser with terser + rollup?
I need to support fairly old browsers... I'd say at last back to IE10 or 11.
I added rollup and terser... I wanted to write ES2017 code with arrow functions, etc... and then have it transpile to a ...
1
vote
0
answers
472
views
Terser minify to ES5
I'm trying to minify a simple js code to es5 using terser api but it's not working.
Here is the code
const code = {
"main.js": "class A{} const a=new A(); console.log(a);"
};
...