-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple transform for some commonjs package #5
Comments
Hi, please provide more details, eg. a reproduction repo will be better, Thx! |
npm: 7.17.0 其实很好懂呀,如果一个包是 由esm转成cjs,他就会被__importDefault这种转一遍,多了个default属性; |
Try to use
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
export default {
plugins: [
viteCommonjs({
exclude: 'your_lib'
})
]
} |
I tried this, but still don't work... |
I upload my demo:https://github.com/SheldonWatson/vite-commonjs-isure |
I have released a new version of Again, just add the plugins: [
viteCommonjs()
] The |
As far as I know, vite will pre-bundling all files that are used by the current page, can you tell me what scene that the code will not handled in Pre-bundling? |
look at this screenshot,this file has been transformed by some "esm to cjs"tools,and was compatibled by the function __importDefault, so 'no_data_png_1' will by wrapped with 'default' property, and with your plugin, you transfromed 'require'
to 'import', which will be transformed twice and wrapped another 'default' property.
In summary, this plugin is not suitable for package that is transformed by 'esm to cjs' tools!
The text was updated successfully, but these errors were encountered: