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

Terser v3.16.0 breaks terser-webpack-plugin #66

Closed
pitops opened this issue Feb 2, 2019 · 54 comments · Fixed by #69
Closed

Terser v3.16.0 breaks terser-webpack-plugin #66

pitops opened this issue Feb 2, 2019 · 54 comments · Fixed by #69

Comments

@pitops
Copy link

pitops commented Feb 2, 2019

The latest terser update (released an hour ago) breaks this plugin.

  • Operating System:
  • Node Version: 10.12.0
  • NPM Version: 6.4.1
  • webpack Version: 4.29.0
  • terser-webpack-plugin Version: 1.2.1

Expected Behavior

Terser to minify my code

Actual Behavior

ERROR in js/main.6e4faa1e7d31caf0fa3b.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/<path>/node_modules/terser-webpack-plugin/dist/minify.js:175:23)

How Do We Reproduce?

Delete yarn.lock

Install terser-webpack-plugin and try to run a production build where the plugin is called

workaround

As a workaround for now if you use yarn you can add a resolution to a fixed terser version. Delete yarn.lock first and node_modules

Example (in your package.json)

"resolutions": {
  "terser": "3.14.1"
}

For npm try the suggestion by @odedi

@kurtinatlanta
Copy link

I added console logging locally and the _terser object is empty ({}) at the point where it's trying to do this:

  const {
    error,
    map,
    code,
    warnings
  } = _terser.default.minify({
    [file]: input
  }, terserOptions);

_terser.default is undefined and therefore it can't dereference _terser.default.minify.

I assume the terser folks must have changed something such that

var _terser = _interopRequireDefault(require("terser"));

no longer gets the right object.

@Xanngo
Copy link

Xanngo commented Feb 2, 2019

I changed _terser.default.minify to _terser.minify and it works

@hutzleo
Copy link

hutzleo commented Feb 2, 2019

https://github.com/rogeriochaves/npm-force-resolutions
for npm

valeriosillari added a commit to valeriosillari/zitronenstrasse that referenced this issue Feb 2, 2019
kasparsd added a commit to kasparsd/burti that referenced this issue Feb 2, 2019
@filipesilva
Copy link

terser/terser#254 should address this.

@3cp
Copy link

3cp commented Feb 2, 2019

Even without any work from terser, you can fix the code in this repo, defensively support both terser 3.16 (esm) and old versions (commonjs).

// import terser from 'terser';
// change to
import {minify} from 'terser';

//... change terser.minify(...) to minify(...)

@vladimiry
Copy link

@huochunpeng the point is that terser made a breaking change without bumping the major version, but just v3.14.1 => v3.16.0. Besides worth taking into the account that it's not just terser-webpack-plugin depends on terser but many other libraries too.

kopax pushed a commit to bootstrap-styled/bootstrap-styled that referenced this issue Feb 2, 2019
@3cp
Copy link

3cp commented Feb 2, 2019

@vladimiry you are right, I understand. I just offer a solution for this repo instead of waiting terser to fix the backward compatibility.

@greyscaled
Copy link

I changed _terser.default.minify to _terser.minify and it works

Thanks ❤️ , verified for me running npm run build with:

devDependencies": {
    ...,
    "@vue/cli-plugin-babel": "^3.4.0",
    "@vue/cli-service": "^3.4.0",
  }

@alexander-akait
Copy link
Member

/cc @fabiosantoscode hopefully you add tests on this regressions, it is break webpack for many developers

@alasdairhurst
Copy link

@ksharlandjiev package-lock is generally quite good for applications but not libraries (since you won't be testing and building using the same dependencies that users of your library will end up with)

@vladimiry
Copy link

vladimiry commented Feb 4, 2019

@ksharlandjiev package-lock is generally quite good for applications but not libraries (since you won't be testing and building using the same dependencies that users of your library will end up with)

Locking the dependencies is useful for libraries too as it makes the build process reproducible.

@kopax
Copy link

kopax commented Feb 4, 2019

Locking the dependencies is not that useful for libraries. You rather want to see things break in your CI and be warned about it. If you must lock your dependency to a certain dependencies, this should be the way to go.

@sidag95
Copy link

sidag95 commented Feb 4, 2019

Awesome @pitops the workaround works, thanks

@manniL
Copy link

manniL commented Feb 4, 2019

terser/terser#251

Resolved

omrilotan added a commit to omrilotan/mono that referenced this issue Feb 4, 2019
fix for terser issue webpack-contrib/terser-webpack-plugin#66 by changing package.json cache key
rthaut added a commit to rthaut/YouTubePopoutPlayer that referenced this issue Feb 4, 2019
* build process overhaul to support upcoming features/updates
* build process is borrowed from `rthaut/deviantART-Filter`

* editor config rules for css files

* set base file type as modules for eslint

* (WIP) Options page designs (experimenting with css frameworks)

* ignore dist directory completely (as userscript version will no longer be offered)

* more build process updates
* switch to using webpack for pages (borrowed from rthaut/simple-gallery-viewer)
* move remaining "source" files to src directory
* switch to JSON format for eslint configs

* continued work on options page
* save settings to (and load from) local storage
* better UX for custom size controls
* removed alternate versions of Options page (the Shoelace.css version seems to be the best fit across Chrome and Firefox)

* start of content script rework to use configured options
* use background script to actually open popout player
* use stored size for window (when configured to use a custom size)

* update build process for vendor files
* use webpack to copy vendor files for pages
* use non-minified vendor files for development
* copy remaining vendor files (defined in manifests for scripts) w/ gulp

* options page enhancements:
* swapped JS alert dialogs w/ inline alert DIVs
* replaced JS confirm dialog w/ `<dialog>` element (plus polyfill)
* fixed actual settings (defaults) not showing after local storage reset

* more build process updates:
* lint manifest files before building
* buold manifests before attempting to copy vendor scripts
* create vendor directory structure for files from manifests explicitely
* give remaining anonymous functions names

* use i18n messages for new Options page

* configure Travis CI

* add Greenkeeper badge to README

* update package dependencies

* change cSpell config file to jsonc to support inline comments

* fix dependencies

* add angular-animate for supporting animations

* convert to using a JS module for defining externals
* use inline switch for using minified vendor files for production mode

* add logic for opening popout player in new tab in current window

* remove start threshold from default options object (for now, anyway)

* fix logging for background script message handler

* fix youtube-nocookie.com domain in manifests

* ensure custom width and height input fields are only required when applicable

* use i18n for options page title

* overhauled alerts
* alerts now auto-dismiss after 5 seconds
* duplicates are automatically removed

* adjust log messages for HTML5Player class

* remove TODO notes for completed functions

* revert to using JS module format for pnpm file

* fix i18n message binding for height label

* fix doc block comments

* change console logging for background Popout class to avoid using groups

* manually offset for window frame when creating new popout window

* add helper methods for saving options and resetting options to defaults

* options page tweaks
* use helper methods to save and reset options
* clear cached dimension options when resetting options
* change internal function declarations

* initialize options to defaults when extension is installed

* ensure lowercase for runtime message listener switch statement

* updated content script code
* move <video> element search logic to YouTubePopoutPlayer class
* fallback to using first <video> element in DOM if no element is provided
* use method for getting <video> element from HTML5Player class
* automatically insert controls and watch for DOM changes when creating new YouTubePopoutPlayer instance
* switch to ES6 functionality for YouTubePopoutPlayer class
* console logging tweaks

* revert to using cSpell.json file (but removed comments) to restore spell check ignore words

* enable use of a command shortcut to open popout player for current video

* adjust Options Page layout to prepare for additional sections

* add UI to Options Page for changing shortcut for opening popout player

* add support for internationalization of command descriptions

* added link to bug report

* fixed typos

* updated Bugzilla link to tracked issue

* disable custom controls on popout player
* expose a new option for hiding custom controls on popout player (default enabled)
* set a flag when opening the popout player (as a GET param)
* prevent initializing YouTube Popout Player content script accordingly

* handle initialization of new options (and removal of old options) during extension update

* display Save button as grayed out when no changes need to be saved

* add support for internationalization of command descriptions

* added link to bug report

* fixed typos

* updated Bugzilla link to tracked issue

* handle initialization of new options (and removal of old options) during extension update

* display Save button as grayed out when no changes need to be saved

* add UI to Options Page for changing shortcut for opening popout player

* hotkey functionality fixes for Chrome
* avoid attempting to reset commands (for description i18n) in browsers that don't support `commands.reset()` (Chrome)
* hide commands that do not have a description (otherwise Chrome shows the `_execute_browser_action` command)
* hide the UI elements for updating shortcuts in browsers that don't support `commands.update()` (Chrome)
* show a help text to point Chrome users to the Extension Shortcuts page to update keyboard shortcuts there

* simplify(?) the `<kbd>` wrap filter/logic

* fix keyboard combo filter default tag

* group similar functionality together in controller

* add TODO for removing console statements from production build of page scripts

* add TODOs for Options page to break some functionality into custom directives

* optionally close the original tab when opening the popout player

* adjust log messages & fix message handler return for unhandled messages

* move radio fields into sub-ngForms and make input names more unique

* allow setting a custom window title preface for the popout player (Firefox only)

* add missing i18n message for number field error message

* build process changes
* set uglify options for webpack (for production bullds)
* define build tasks/scripts for development vs production

* convert warning logs to info in content script (to avoid showing in Chrome as errors)

* options page enhancements
* use FontAwesome for icons
* show reminders to save changes through form (when changing settings)

* watch for image/logo changes and rebuild (and rebuild logos on manifest changes)

* add docblocks for utility functions

* harden `GetDimensionForScreenPercentage()` utility function

* improve Firefox-only CSS fixes for options page

* options enhancements and rework
* expose new controls for toggling autoplay and looping
* setup Embedded Player URL for looping single videos and playlists
* rework controls option to allow hiding all controls
* always insert context menu entry, but only insert button when appropriate
* moved "Close Original Window/Tab" option to Advanced section
* options page layout tweaks and comments

* WIP(?) updated logo and button icon - maybe not final

* remove completed TODO for dropping console statements in page scripts

* scripts for watching source files and building either development or production version

* change page action button title to indicate what clicking it does

* reword "native" option for controls setting to "standard"

* improved handling and validation for settings with multiple options
* ensure the model value for `<select>` inputs is actaully valid
* add warning message above save button when form fields are invalid
* add default cases for switch statements for options in background script

* add support for font awesome icons in alerts

* add icons to feldset legends on options form

* used stacked icons for per-device warning

* do not attempt to set `listType` for embedded player; setting it incorrectly causes unexpected behavior

* filled in some more docblock comments

* use URL search params for extracting list ID from URL

* add TODO notes for building URL (related to `autoplay` and `list`/`playlist` params)

* unused test CSS for animating the icon on the popout player button

* fix `<kbd>` wrapping for error messages when updating keyboard shortcuts

* new screenshots and promo images

* update package description

* update version to 3.0.0

* update README
* add Features section with overview of features
* add Permissions section to describe extension permissions
* add information for opening Options page to Usage section
* add Options section to describe configurable options

* initial config file for AllContributors bot

* add ignored words to spellcheck file

* markdown lint config file

* add more information about automatic window sizing

* prevent field name cells from wrapping to multiple lines

* add MDN documentation link for Keyboard Shortcuts

* updated promo screenshot, moved PSDs, and added screenshots of Options page

* use new cropped screenshots of Options page

* remove old preview file

* updated logo to use new icon style

* updated icon files

* updated Page Action screenshots with new logo

* update Promo screenshot with new logo

* new/updated promotional images for Chrome and Firefox pages/listings

* add table of contents

* add spaces around some more of the `<kbd>` tags

* added FAQ section

* configure more rules for Markdown Lint

* attempt to standardize casing for "YouTube Popout Player" (name) vs "popout player"

* add example screenshot for "Video unavailable" error

* initial project page

* setup local jekyll development and switch to custom theme

* moved screenshots to /docs and updated promo screenshot

* new theme and split sections into pages

* reduced README content to basics

* point homepage to project page URL

* fix dialog opening outside of viewport on Options page in Firefox

* add build & watch scripts for docs

* add link to options page from getting started page

* hide excluded pages in category dropdowns in nav menu

* add waves effect to buttons in header and footer

* drop top heading to h3 on default layout

* list Frequently Asked Questions page as FAQ in menus

* show Home page on nav menu

* add shadow to features list on home page

* reworked Options page layout to use cards

* add package-lock.json to fix(?) failing builds
(webpack-contrib/terser-webpack-plugin#66)

* add package-lock.json to fix(?) failing builds
(webpack-contrib/terser-webpack-plugin#66)

* pin terser and terser-webpack-plugin

* use webRequest API to explicitly set Referer header for popout player

* remove unneeded `web_accessible_resources` manifest key for images

* sort imported constants alphabetically

* add no-unsanitized eslint plugin

* update permissions page
* convert to cards layout
* add screenshot of permissions request (Firefox)
* reword domains permission section

* increase minimum version for Firefox
jesstelford added a commit to jesstelford/mdx-deck that referenced this issue Feb 4, 2019
For example, I was hit by this bug: webpack-contrib/terser-webpack-plugin#66 And mdx-deck was silently failing (and worse; making it look like it was successful).

This patch will guard against these kinds of issues in the future.
@afide1
Copy link

afide1 commented Feb 6, 2019

The latest terser update (released an hour ago) breaks this plugin.

  • Operating System:
  • Node Version: 10.12.0
  • NPM Version: 6.4.1
  • webpack Version: 4.29.0
  • terser-webpack-plugin Version: 1.2.1

Expected Behavior

Terser to minify my code

Actual Behavior

ERROR in js/main.6e4faa1e7d31caf0fa3b.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at minify (/<path>/node_modules/terser-webpack-plugin/dist/minify.js:175:23)

How Do We Reproduce?

Delete yarn.lock

Install terser-webpack-plugin and try to run a production build where the plugin is called

workaround

As a workaround for now if you use yarn you can add a resolution to a fixed terser version. Delete yarn.lock first and node_modules

Example (in your package.json)

"resolutions": {
  "terser": "3.14.1"
}

For npm try the suggestion by @odedi

"Thank you!"

@pitops
Copy link
Author

pitops commented Feb 6, 2019

@afide1 Hey, its been fixed, all you need to do is update terser-webpack-plugin to v1.2.2 +

cecilia-sanare added a commit to salte-auth/salte-auth that referenced this issue May 4, 2022
* Switched back to npm from yarn
* Locked down the terser version to fix an issue with webpack

closes #307
relates webpack-contrib/terser-webpack-plugin#66
cecilia-sanare added a commit to salte-auth/salte-auth that referenced this issue May 4, 2022
* Switched back to npm from yarn
* Locked down the terser version to fix an issue with webpack

closes #307
relates webpack-contrib/terser-webpack-plugin#66
josh-taylor-k3 pushed a commit to josh-taylor-k3/crm-application-using-symfony that referenced this issue Nov 4, 2024
…rsion (#22252)

* BAP-18304: Prevent installation of 3.1 LTS release on outdated PHP version

* locked terser package version because of BC changes, see webpack-contrib/terser-webpack-plugin#66
josh-taylor-k3 pushed a commit to josh-taylor-k3/crm-application-using-symfony that referenced this issue Nov 4, 2024
…rsion (#22252)

* BAP-18304: Prevent installation of 3.1 LTS release on outdated PHP version

* locked terser package version because of BC changes, see webpack-contrib/terser-webpack-plugin#66
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

Successfully merging a pull request may close this issue.