aiji42/remix-esbuild-override

how to use plugins with import syntax

marvinwu opened this issue · 3 comments

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?

@marvinwu
Try it!

const GlobalsPolyfills = require("@esbuild-plugins/node-globals-polyfill").default

Close this issue. If you have any other questions, please reopen it again.

@aiji42 Works like a charm! Thanks a lot AijiUejima, appreciate the help very much