how to use plugins with import syntax
marvinwu opened this issue · 3 comments
marvinwu commented
Hi AijiUejima,
Thanks much for this great plugin, I have a silly question, for some of the esbuild it is using import rather than requires to import the plugins. Eg. I am interested in using this one - node-globals-polyfill
const GlobalsPolyfills = require("@esbuild-plugins/node-globals-polyfill")
withEsbuildOverride((option, { isServer, isDev }) => {
// update the option
console.log(option)
option.plugins = [
GlobalsPolyfills({
process: true,
buffer: true,
define: { "process.env.var": '"hello"' }, // inject will override define, to keep env vars you must also pass define here https://github.com/evanw/esbuild/issues/660
}),
...option.plugins,
]
return option
})
then it says GlobalsPolyfills is not a function
any hint on how to use the plugins with import directive?
aiji42 commented
@marvinwu
Try it!
const GlobalsPolyfills = require("@esbuild-plugins/node-globals-polyfill").default
aiji42 commented
Close this issue. If you have any other questions, please reopen it again.