138 questions
0
votes
0
answers
47
views
Terser webpack error while building next.js project
I get these errors when I try to build my nextjs project
static/chunks/36443.1f4a0592caf86eec.js from Terser
invalid unicode code point at line 1 column 454144
I tried removing node_modules and ...
0
votes
1
answer
102
views
How do I get better source code maps from my compiled and minimized TypeScript code?
My rollup config is generating source maps for me. They just aren't very good source maps. They aren't doing a good job of restoring full original variable and function names, only a smattering of the ...
1
vote
1
answer
757
views
Vite terser minifier doing nothing
Consider this repro script.
#!/bin/bash -x
rm -rf my-vanilla-lib
npm create vite@latest my-vanilla-lib -- --template vanilla
cd my-vanilla-lib
npm i
cat <<EOL > vite.config.js
export default ...
0
votes
1
answer
46
views
Overriding Collectstatic and Manifestic file storage
I am trying to integrate terser js minification in a django collectstatic command , by overriding the CompressedManifestStaticFileStorage of whitenoise in below code , but the def _save() method ...
1
vote
0
answers
498
views
preserving comments with vite?
I'm trying to get vite to user terser and preserve some comments. Well, any comments at this point. This is the build section of my vite config:
export default defineConfig({
plugins: [
vue(),
...
0
votes
1
answer
126
views
ReactDOMServer's renderToString method throwing error : clearProviders is not a function
We are using server side rendering with GraalVM. Application is throwing below error
org.graalvm.polyglot.PolyglotException: TypeError: <this>.clearProviders is not a function
at <js&...
0
votes
0
answers
404
views
Removing console.logs using "drop_console" in metro.config does not work
Using the drop_console option into metro.config.js as per documentation here does not remove console.logs from the production build.
const { getSentryExpoConfig } = require('@sentry/react-native/metro'...
0
votes
1
answer
495
views
Webpack 5 (TerserPlugin) - "Import" statement may only appear at the top level
I am unable to minify and building code with Terser in Webpack.
I get the following error while running my production build:
cart-ts.js from Terser plugin
"Import" statement may only appear ...
3
votes
1
answer
339
views
Next.js Build Fails Due to Terser Error With External NPM Package
I'm experiencing a build failure in my Next.js project when attempting to create an optimized production build (next build). The build process fails specifically due to an issue with Terser, which ...
1
vote
0
answers
48
views
gulp concat variables is redeclared
In my index.html, I will call a index.js file
and that file will import other files/variable.
It keeps on say some variables is redeclared after compiling the js files into one file.
As I need to ...
2
votes
0
answers
97
views
Ruby on Rails - Sprockets removes sourceMappingURL and sourceURL from module in browser
First of all I'm upgrading rails from 4 to 6 version.
I have a separate fronted project that's based on webpack and as a result it produces js output file. Let's name it ui.js
This file is later taken ...
0
votes
0
answers
477
views
How to remove comments from sourcemap created with Rollup and terser for web app javascript bundle?
How can I configure Rollup and it's terser plugin to create a sourcemap for my web app's minified javascript bundle, that doesn't have any of my javascript source code comments? I am using terser to ...
0
votes
0
answers
35
views
Standard model for separation of a JJavaScript app with production and developer components
I am new to JavaScript so forgive the simple question - after doing a lot of research, I am even more confused...
The app I am writing had production (display of data etc.) and developer (tools to ...
0
votes
1
answer
263
views
How to run Terser from PHP script?
I have PHP script that automates my dev-to-production proces. I want to use Terser to minify the JS in my project. But when I fire it with the php exec() function, I get a result value of 1.
This ...
0
votes
1
answer
136
views
Call node from powershell
I am trying to create a yml file for a Github locally hosted action runner that calls an npm module called "terser" to minify js and css.
- name: Minify_JS
if: ${{ contains(inputs....
1
vote
0
answers
246
views
Is there a way to tree shake out a function called in a class method?
Let's consider this code :
class Foo {
type;
constructor(type) {
this.type = type;
}
foo() {
this.type === 'animation' ? create() : createNoop();
}
}
new Foo('animation')
...
1
vote
0
answers
235
views
Minifying JS: Option to compile imports into the minified version
I'm trying to do a JS compiler in Node for websites, but I'm hitting a snag.
My compiles keep imports set in the JS. So when its read by the browser it says Uncaught SyntaxError: Cannot use import ...
1
vote
0
answers
374
views
How to preserve dedicated comment with Webpack's Terser?
I want do preserve dedicated comments which contain delimiters for Thymeleaf's processing engine. When Thymeleaf finds these delimiters inside comments, it will parse the content, remove the comment ...
0
votes
1
answer
228
views
How to ignore code tag contents with html-minifier-terser
The problem happens when I use text editor on admin part of website with enabled prerender mode.
html-minifier-terser dies when it meets contents of <.code> tag
What could be a workaround for ...
0
votes
2
answers
2k
views
Npm scripts - how to minify files from a folder and save them into another?
I'm using npm scripts to compile and minify sass and potentionally javascript files.
However, I'm looking for at way to specify a source folder of *.js files and have them minified and saved in a ...
0
votes
1
answer
432
views
terser removes the function
I am using terser to compress my code. But it turns out that it removes a function that is called only in html code (I understand that I set module: true)
I also set dead_code: false to keep ...
1
vote
0
answers
353
views
webpack terser minify imported library
I'm using webpack for an internal project. The project is set to be minified with TerserPlugin.
The project also uses paper js library to deal with some SVG transformations.
The issue I have is when I ...
10
votes
2
answers
11k
views
vite: use "keep-names" esbuild flag for production build
one of our third party libraries requires us to preserve specific function names. in webpack we did that with terser.keep_fnames. esbuild has https://esbuild.github.io/api/#keep-names so we'd like to ...
0
votes
1
answer
573
views
ERROR in bundle.js from Terser Invalid assignment bundle.js
I have a problem with terser-webpack-plugin I can't minify my bundle the error is
ERROR in bundle.js from Terser Invalid assignment bundle.js
I have the version of "terser-webpack-plugin": &...
1
vote
0
answers
2k
views
Sourcemap is likely to be incorrect: a plugin (terser) was used to transform files, but didn't generate a sourcemap for the transformation
I'm trying to upgrade mui, rollup, nodejs and npm but encountered this errorenter image description here
tsconfig
all packages are in their latest version
tried these:
Rollup is not generating ...
0
votes
1
answer
486
views
Problems with VS Code JavaScript Intellisense and ES6 Import with Minified & Non-minified Version of JS
Below is my Firebase hosting project folder structure:
projectFolder/store/public/scripts/*.min.js
projectFolder/src/*.js
After running terser, all my projectFolder/src/*.js will be minified to ...
2
votes
2
answers
2k
views
Webpack build results Terser Error: Unexpected token: punc ())
I've been cleaning up my npm audit errors and after I was done I could not execute npm tun build anymore.
Error
ERROR in web/themes/custom/js/funds-chunk.js from Terser
Unexpected token: punc ()) [...
2
votes
1
answer
1k
views
Vite: This module can only be imported inside a service worker
After a pnpm package update, I can't start my SvelteKit project anymore. Something is messy with the tooling: pnpm, vite, sass, terser or sveltekit, I don't know.
> pnpm run dev
VITE v4.0.0 ready ...
0
votes
1
answer
429
views
How to mangle function names used in event attributes with html-minifier-terser?
I am using the latest https://github.com/terser/html-minifier-terser 7.0.0 (https://www.npmjs.com/package/html-minifier-terser)
The readme states
Minify JavaScript in script elements and event ...
0
votes
0
answers
145
views
Change JavaScript output before terser kicks in in Angular
Is it possible in an Angular 13 project to change the content in the generated main.js file before it is given to the minifier/optimizer/obfuscator (in Angular, it is terser)?
A very exotic ...
4
votes
2
answers
2k
views
Terser: Only mangle matched property names from regex
I want to keep ALL my variables and function names, even the private ones, and only mangles the ones that match the regex.
The docs say:
regex (default: null) — Pass a RegExp literal or pattern ...
1
vote
0
answers
211
views
Grunt-terser failing to minify React JSX code on Sails
I am using browserify with babelify to transpile React code from ES6 and everything went smoothly until trying to minify using Uglify and discovered that Uglify doesn't do ES6 syntax, so I switched to ...
0
votes
1
answer
984
views
Vue 2: Minify JS files using Terser
I want to compress my js files using Terser Plugin.
Here is my dependencies
"dependencies": {
"axios": "^0.26.0",
"core-js": "^3.6.5",
&...
0
votes
0
answers
539
views
Terser setting to minify/hoist the this variable and properties
Is there any way for terser to minify/hoist the this variable so it does not appear repeated as often in the bundle?
Example code:
class MyClass {
constructor(handler) {
this.handler = ...
5
votes
0
answers
2k
views
webpack/terser: How can I exclude a package from minification, but still include that package in the packed result?
I've found a number of solutions for excluding particular modules from minification, but all of the solutions I've seen so far not only skip minification of those packages, they cause those packages ...
0
votes
1
answer
203
views
Minify calls to Math, Number, etc. with Terser
The code that Terser produces for my project contains many calls to the Javascript Math object and I am wondering if there is an easy way to minify these calls.
Here is a screenshot of part of the ...
1
vote
1
answer
6k
views
Cannot find module terser-webpack-plugin when run yarn serve in Vue 3 project
I just created a Vue 3 project using Vue CLI using the default options, and when I try to run using yarn serve command I got this error
Error: Cannot find module '.../node_modules/terser-webpack-...
1
vote
1
answer
4k
views
Minify JS with VS code extension
I need: minify JS file with extension from the store, but I can't find an option to remove whitespace between html tags in variables
I use: JS & CSS Minifier (Minify) - https://marketplace....
2
votes
1
answer
680
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__*/...
4
votes
1
answer
2k
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 ...
3
votes
1
answer
1k
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)=...
2
votes
2
answers
4k
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 ...
5
votes
0
answers
2k
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-...
3
votes
2
answers
3k
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 ...
2
votes
0
answers
290
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 ...
2
votes
0
answers
289
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 ...
4
votes
3
answers
2k
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
181
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
2
answers
1k
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 ...
4
votes
2
answers
2k
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 ...