Open vskh opened 1 year ago
@vskh I've hit this same issue. Did you find a way to work round it?
Just to follow up, I found that the interop
option solved this:
{
dir: 'dist/cjs',
format: 'cjs',
sourcemap: true,
+ interop: 'auto',
},
Expected Behavior
Following import:
import userEvent from "@testing-library/user-event";
to be transpiled into:
var userEvent = require('@testing-library/user-event').default;
because '@testing-library/user-event' defines
exports["default"]
andObject.defineProperty(exports, '__esModule', { value: true });
.From 'plugin-commonjs' docs:
Actual Behavior
Following import:
import userEvent from "@testing-library/user-event";
to be transpiled into:
var userEvent = require('@testing-library/user-event');
Additional Information
Existing behavior causes compiled code to fail at runtime because it tries to access properties of default export, whereas
require
result is an object with only 'default' key.