@babel/runtime 7.13.10 breaking on JSPM

Bug Report

  • I would like to work on a fix!

Current behavior

Input Code

Loading @babel/runtime@7.13.10/helpers/interopRequireWildcard.js includes a require to @babel/runtime/helpers/typeof which is mapped to resolve to @babel/runtime@7.13.10/helpers/esm/typeof.js in all environments that aren’t Node.js environments by the exports definitions.

This file then also uses the import pattern:

var _typeof = require("@babel/runtime/helpers/typeof")["default"];

Where accessing the default off of the helpers/esm/typeof.js file makes _typeof undefined.

Expected behavior

"require" should not remap to an ESM module, or if it does the interop should take into account the varying signature of the exports.

Possible Solution

I’m not sure what would be best actually. Ideally using relative paths in the first place would avoid this. Alternatively using the "require" condition instead of the "node" condition. If it is really desired to replace the CJS require statements with ES modules then the Webpack / build-tool-specific "module" condition could be used.

1 possible answer(s) on “@babel/runtime 7.13.10 breaking on JSPM

  1. Thanks for the quick response here @nicolo-ribaudo, you’re right this looks like a bug if it is incorrectly matching the "import" condition. Let me see if I can fix that up and reopen if I’m still seeing any issues.