wranglerjs is too rigid in what version of webpack it uses to build projects

Created on 14 Sep 2020  路  2Comments  路  Source: cloudflare/wrangler

from @1000hz : the parser webpack 4 uses (acorn) doesn't support optional chaining / nullish coalescing operators. wranglerjs uses its own version of webpack (4.x). TypeScript target ES2020/ESNext doesn't transpile these operators
webpack 5 (which has been in beta forever) uses a newer version of acorn with support for these operators
but there's no way to override what version of webpack wrangler will use

category - maintenance subject - webpack

Most helpful comment

I think the long-term solution to this problem is to have wrangler defer building to project scripts, i.e.
if there's a package.json file

npm run wrangler:build
npm run build    # if above doesn't exist

or if there's a cargo.toml file

cargo run wrangler:build
cargo build    # if above doesn't exist

and only fallback to using a bundled version of webpack if none of these exist.

All 2 comments

I think the long-term solution to this problem is to have wrangler defer building to project scripts, i.e.
if there's a package.json file

npm run wrangler:build
npm run build    # if above doesn't exist

or if there's a cargo.toml file

cargo run wrangler:build
cargo build    # if above doesn't exist

and only fallback to using a bundled version of webpack if none of these exist.

Supporting arbitrary scripts seems like a really good idea actually, and would allow people to choose their own JS bundling tools (e.g. rollup, etc).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nickbalestra picture nickbalestra  路  5Comments

ispivey picture ispivey  路  4Comments

adaptive picture adaptive  路  5Comments

xtuc picture xtuc  路  5Comments

EverlastingBugstopper picture EverlastingBugstopper  路  3Comments