2

I have pretty fresh rails application and I'm trying to add uppy file uploader to it. Unfortunately when requiring @uppy/core file I am presented with Cannot assign to read only property 'exports' of object '#<Object>' error.

This error is caused by having both Ecma's import and CommonJS' module.exports = in a single file. I have checked uppy source code in node_modules to find that the offending file does not have import - however it is present in a version received by the browser, just under "use_strict":

import _regeneratorRuntime from "@babel/runtime/regenerator";

This suggests that babel plugin decided to inject import statement into a CommonJS file, making it impossible to load that file.

Removing the @babel/plugin-transform-runtime' from babel.config.js resolved the issue - but it also broke @babel/preset-env which expects global regenerationRuntime object.

I have created a minimal reproduction application here: https://github.com/BroiSatse/babel-issue. It is a fresh installation of rails, no js config changes except for @uppy/core dependency with single route to dummy action and import Uppy from '@uppy/core' in webpack/packs/application.js`.

Any help appreciated, I don't even know where to raise that issue on github.

BroiSatse
  • 44,031
  • 8
  • 61
  • 86

0 Answers0