You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CommonJS module often omit the .default statement when requiring a module with a default export:
consta=require('./a')
a.js
module.exports=1
But the bundling of swc(and also some other tools) does not handle this the above way, instead we should add .default manually:
consta=require('./a').default
I'm wondering is there any way to import the module without modifying the require statement, for there are many packages they'd already omitted .default, and we are not supposed to change them.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
CommonJS module often omit the
.default
statement when requiring a module with a default export:a.js
But the bundling of
swc
(and also some other tools) does not handle this the above way, instead we should add.default
manually:I'm wondering is there any way to import the module without modifying the require statement, for there are many packages they'd already omitted
.default
, and we are not supposed to change them.Beta Was this translation helpful? Give feedback.
All reactions