Open zhaoyao91 opened 4 years ago
when building umd module, it should not rename lodash to lodash-es
Ah yep, that's probably required for UMD. Currently the code only checks for CJS. Should be a one-liner fix here: https://github.com/formium/tsdx/blob/8b148cea34c1852f6fcf6e94a3758d7a9f46d9b2/src/babelPluginTsdx.ts#L72
EDIT: actually I'm not so sure this isn't due to an upstream bug. ~There's a CJS plugin for Rollup used that should convert lodash-es
too.~ (Misinterpreted that plugin, it does the inverse) The error is coming from Babel and not Rollup, and it's complaining about location of import
and not usage of import
🤔
Though I think the one-liner fix would still resolve this error.
How do I disable this feature ?
@Morphexe not sure what you mean, this is a bug, not a feature.
I think one can do a partial workaround for this by configuring babelrc
with a dummy entry:
module.exports = {
// ...
plugins: [
// ...
['babel-plugin-transform-rename-import', { replacements: [{ original: '', replacement: '' }] }]
]
}
But conversely, that'll probably break ESM builds
So https://github.com/formium/tsdx/issues/912#issuecomment-717002753 revealed a similar issue that points to upstream https://github.com/rollup/plugins/issues/304 which would seem to confirm my suspicion that there's a bug upstream.
Per my comment there:
That seems to be fixed in v12.0.0, but that version has an undocumented requirement on Rollup 2, which is a very breaking change slated for v0.15.0.
Will have to add a test for this in v0.15.0 to ensure it works after the upgrade.
@Morphexe not sure what you mean, this is a bug, not a feature.
I think one can do a partial workaround for this by configuring
babelrc
with a dummy entry:// ... plugins: [ // ... ['babel-plugin-transform-rename-import', replacements: [{ original: '', replacement: '' }] ] }
But conversely, that'll probably break ESM builds
Can you post a working example please? The snippet syntax looks borked...
@axedre ah looks like it was missing a closing bracket, I updated my comment
That still doesn't look like valid javascript. For anyone else stumbling on this, check out: https://www.npmjs.com/package/babel-plugin-transform-rename-import.
Current Behavior
To export umd module, I would like to include all modules into the bundle, so I config the rollup
but when building, it crashes:
Expected behavior
Suggested solution(s)
when building umd module, it should not rename lodash to lodash-es
Additional context
Your environment