Skip to content

v2.36.2 fails webpack production builds #657

@avatarneil

Description

@avatarneil

Describe the problem

Attempting to create a production webpack build with the recently released Auth0 v2.36.2 results in quite a few warnings/errors being thrown, the most critical (and relevant to this issue) of which are:

WARNING in ../node_modules/.pnpm/[email protected]/node_modules/vm2/lib/main.js 99:24-48
Module not found: Error: Can't resolve 'coffee-script' in '/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/vm2/lib'
 @ ../node_modules/.pnpm/[email protected]/node_modules/vm2/index.js 3:0-38
 @ ../node_modules/.pnpm/[email protected]/node_modules/degenerator/dist/src/index.js 6:14-28
 @ ../node_modules/.pnpm/[email protected]/node_modules/pac-resolver/dist/index.js 6:22-44
 @ ../node_modules/.pnpm/[email protected]/node_modules/pac-proxy-agent/dist/agent.js 26:39-62
 @ ../node_modules/.pnpm/[email protected]/node_modules/pac-proxy-agent/dist/index.js 7:32-50
 @ ../node_modules/.pnpm/[email protected]/node_modules/proxy-agent/index.js 16:20-46
 @ ../node_modules/.pnpm/[email protected][email protected]/node_modules/superagent-proxy/index.js 6:17-39
 @ ../node_modules/.pnpm/[email protected]/node_modules/rest-facade/src/Client.js 15:0-27
 @ ../node_modules/.pnpm/[email protected]/node_modules/rest-facade/src/index.js 2:10-29
 @ ../node_modules/.pnpm/[email protected]/node_modules/auth0/src/management/index.js 7:20-56
 @ ../node_modules/.pnpm/[email protected]/node_modules/auth0/src/index.js 8:20-43
 @ ./index.js 1:14-30

and

ERROR in bundle.js
bundle.js from Terser plugin
Invalid function parameter [bundle.js:82271,21]
   at js_error (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:550:11)
   at croak (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:1274:9)
   at binding_element (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:2026:13)
   at parameter (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:1830:17)
   at parameters (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:1804:25)
   at _function_body (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:2077:19)
   at function_ (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:1728:20)
   at /Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:2585:16
   at _embed_tokens_wrapper (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:1339:26)
   at concise_method_or_getset (/Users/neil/Documents/projects/auth0-vm2-webpack-repro/node_modules/.pnpm/[email protected]/node_modules/terser/dist/bundle.min.js:2792:31)

After these errors are thrown, the webpack build fails.

What was the expected behavior?

Successful webpack build!

Reproduction

I made an example repo which reproduces this issue https://github.com/avatarneil/auth0-vm2-webpack-repro

Environment

  • Node: v15.11.0
  • Auth0: v2.36.2
  • Webpack: 5.42.1, in production mode (note: development builds seem to be fine)

Additional Details

Upon some investigation, it appears that Auth0 v2.36.2 introduced a dependency on https://github.com/patriksimek/vm2/. It appears that this dependency breaking webpack builds is a known issue (see patriksimek/vm2#68), and the maintainer of the package has been resistant to making any changes to fix this, simply stating that this package is not webpack compatible. Unfortunately, this is very far down in the dependency tree for Auth0; in order to resolve this issue, I think that rest-facade may need to be subbed out for another library which does not contain vm2 anywhere in the dependency tree.

I do hope that this issue can be resolved, as I am now forced to lock my auth0 version at an earlier version that does not contain this dependency... Of all the packages to keep up-to-date, I think this is one of the most important 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions