Questions tagged [terser]

Terser is a JavaScript parser and mangler/compressor toolkit for ES6+ (ECMAScript 6+ / JavaScript 6+)

Terser is a JavaScript parser and mangler/compressor toolkit for ES6+ (ECMAScript 6+ / JavaScript 6+). It is a fork of uglify-es which doesn't support ES6+ any longer.

128 questions
3
votes
1 answer

Heroku build fails because npm is missing

I am using terser as a minification step in a gradle task. But heroku does not have the npm binary during the build. This is what i tried val installTerser = tasks.create("installTerser") { commandLine("npm", "install", "-g",…
Nikky
  • 498
  • 2
  • 9
3
votes
0 answers

Custom terser-webpack-plugin cache invalidation in Webpack 4

I am upgrading a large app from Webpack v3 to v4. With Webpack 3, we had a custom post-Webpack mechanism for UglifyJS. It stored post-processed JS files in a given directory for 24 hours, and its filename was a hash generated from its content. …
johnmarinelli
  • 309
  • 3
  • 11
3
votes
2 answers

How to use Terser with webpack

I am using Webpack 6.10.2 with Vue 3.9.3. This install uses Uglify.js which throws an error when I run npm run build because it cannot work with ES6. To get round this, I have removed Uglify form webpack.config.js as recommended and I have…
Thomas Bishop
  • 105
  • 1
  • 1
  • 7
3
votes
1 answer

Use terser webpack plugin instead of uglify when copying sources via plugin

I have following packages in my webpack.config.js: const CopyWebpackPlugin = require("copy-webpack-plugin"); const TerserPlugin = require("terser-webpack-plugin"); const UglifyJS = require("uglify-es"); And this is a part of my config that uses…
dhilt
  • 18,707
  • 8
  • 70
  • 85
3
votes
2 answers

Webpack 4 disable minification but retain-tree shaking

I am looking for a way of disabling minification of files but retaining tree-shaking. Terser Plugin takes care of tree shaking but apparently only when minimize is set true, and in Webpack production mode. optimization: { minimize: true } Where…
3
votes
2 answers

Is OBR segment required to view the OBX segment attachments in HL7 message?

I'm trying to parse an HL7 message file which is of version 2.3.1. OBX segment is coming as null when the message is parsed. If I don't have OBR segment in HL7 message, Terser is failing to fetch the OBX segment values (it's returning null values),…
Madesh
  • 55
  • 7
3
votes
1 answer

How to keep whitespace & indentation with Terser plugin in webpack?

How do I build my react app using webpack and skip the part of minimize steps that removes whitespaces. I don't want to turn off minimize but just want to skip whitespace removal. I tried minimizer: [ new TerserPlugin({ parallel:…
Sang Park
  • 382
  • 2
  • 17
3
votes
0 answers

Build is failing giving this error, how to read security context for proper error?

Build is failing throwing this error, please help me to understand security context. Project is with React and node server. Suspecting that problem is with Terser when I migrated to webpack 4 from webpack 3 clean-webpack-plugin:…
Pranjal Koshti
  • 147
  • 2
  • 8
2
votes
2 answers

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 string to only mangle property matching the regular…
Julian
  • 698
  • 2
  • 8
  • 17
2
votes
0 answers

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 to be completely omitted from webpack's output,…
kshetline
  • 12,547
  • 4
  • 37
  • 73
2
votes
1 answer

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__*/i_am_dropped_if_x_is_not_used() But, usually, if I define a pure…
Peter Gerdes
  • 2,288
  • 1
  • 20
  • 28
2
votes
1 answer

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 token: punc (.)…
Ricardo Gaefke
  • 823
  • 1
  • 7
  • 21
2
votes
2 answers

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 works.
AaronJ
  • 1,060
  • 10
  • 24
2
votes
0 answers

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 to be fully functional also in development mode…
AntonOfTheWoods
  • 809
  • 13
  • 17
2
votes
1 answer

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 of a difference that makes. I copied the…
kshetline
  • 12,547
  • 4
  • 37
  • 73
1 2
3
8 9