razzle: [babel-preset-razzle] TypeError: [BABEL] commonjsPlugin.apply is not a function

🐛 Bug report

After integrating razzle to an existing project, when I go to run razzle start, I get the following error:

~/node_modules/babel-preset-razzle/babel-plugins/commonjs.js:4
  const commonjs = commonjsPlugin.apply(null, arguments);
                                  ^
Error: Module build failed (from ./node_modules/razzle/config/babel-loader/razzle-babel-loader.js):
TypeError: [BABEL] ~/server/app.js: commonjsPlugin.apply is not a function (While processing: "programmatic item")

which works after I change this line to the following:

const commonjs = commonjsPlugin.default.apply(null, arguments);

I can’t share any of the existing code, but I can share any relevant dependencies that could be related to this, such as babel plugins, etc… FWIW, I’m also using the newBabel experimental flag, because the root of the project uses a babel.config.js, which seems to get ignored otherwise.

Current Behavior

Expected behavior

It shouldn’t error

Reproducible example

Suggested solution(s)

I’m not exactly sure. This bug doesn’t happen when using one of the example templates, so there might be an edge case with my project I’m missing.

Additional context

Your environment

Software Version(s)
Razzle ^3.3.11, ^3.3.12
Razzle Plugins none.
Node v14.13.0
Browser
npm/Yarn yarn v1.22.10
Operating System macOS 10.15.7
TypeScript
React ^16.10.2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17

Most upvoted comments

Fixed in v3.3.13