Closed nosferatu500 closed 2 years ago
In Vite, the module exports are loaded by default Browser module
I tried to change the default behavior by configuration, such as
esmodule([
{ 'file-type': 'file-type/index.js' },
])
However, there is a problem with the operation of the code packaged with Vite or esbuild, and I am trying to solve this problem with Webpack
I tried webpack and it works normally.
I am rewriting the core logic part, and the next version will support webpack built.
like this, e.g.
esmodule([
{ 'file-type': 'file-type/index.js' },
], {
webpack: (config) => config, // support custom webpack config, if you choose it.
// or
vite: (config) => config, // support custom vite config, if you choose it
})
I'll fix it soon. Just a moment, please. 😄
Thank you!
Hey!
vite-plugin-esmodule@1.1.0
has been released
You can configure blow options in your vite.config.js
file for resolve the BUG
esmodule([
'file-type',
// or
// { 'file-type': 'file-type/index.js' },
// When webpack is used, the `exports.node` filed will be hit first
], {
webpack: true,
})
Hi! Thank you for this update.
But I just checked it and I still have the same issue. I tried to use both 'file-type'
and { 'file-type': 'file-type/index.js' }
:(
Case 1: plugins: [esmodule(["execa", "file-type"], { webpack: true })],
Error: getDefaultExportFromCjs is not a function
Case 2: plugins: [esmodule(["execa", { "file-type": "file-type/index.js" }], { webpack: true })],
Error: [vite:load-fallback] Could not load /Users/***/node_modules/.vite-plugin-esmodule/execa (imported by electron/electron.ts): EISDIR: illegal operation on a directory, read
vite-plugin-esmodule@1.1.2
fix the BUG 😅
You can see the demo file-type.ts
With v1.1.2 I still had some issues, but with v1.2+ everything looks fine. Thanks!
As time goes on, everything will be all right 😄
Hello, thank you for this plugin.
It's works smoothly with execa but I have one issue with another esm package;
I'm trying to use it with file-type but I'm getting an error "getDefaultExportFromCjs is not a function"
What can be a problem?