You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello again! Following up the discussion at crxjs/chrome-extension-tools#124. I'm now trying to use @extend-chome/messages and the built file ends up importing another file like this:
This, in turn, throws Cannot use import statement outside a module. As you already may know from the linked issue, content-script.ts was added as an input file in rollup.config.js. I tried returning an array from rollup config by having a configuration for content-script.ts and another for manifest.ts and that kind of works but simpleReloader is now working right.
rollup.config.js looks like this:
importpathfrom'path'importresolvefrom'@rollup/plugin-node-resolve'importcommonjsfrom'@rollup/plugin-commonjs'importtypescriptfrom'@rollup/plugin-typescript'import{chromeExtension,simpleReloader}from'rollup-plugin-chrome-extension'import{emptyDir}from'rollup-plugin-empty-dir'importzipfrom'rollup-plugin-zip'importreplacefrom'@rollup/plugin-replace'constisProduction=process.env.NODE_ENV==='production'exportdefault{input: ['src/manifest.ts','src/content-script.ts'],output: {dir: 'dist',format: 'esm',chunkFileNames: path.join('chunks','[name]-[hash].js'),},plugins: [replace({'process.env.NODE_ENV': isProduction
? JSON.stringify('production')
: JSON.stringify('development'),preventAssignment: true,}),chromeExtension(),// Adds a Chrome extension reloader during watch modesimpleReloader(),resolve(),commonjs(),typescript(),// Empties the output dir before a new buildemptyDir(),// Outputs a zip file in ./releasesisProduction&&zip({dir: 'releases'}),],}
Thank you!
The text was updated successfully, but these errors were encountered:
Makes sense. Rollup outputs the content script as ESM, but Chrome Extensions don't support static imports in content scripts. There are workarounds, but they get complicated quick, so I think the best solution for now is to output the content script in a different format (IIFE works well).
A full rewrite of rollup-plugin-chrome-extension is in beta, and I'm going to add support for the new Scripting API. Thanks for letting me know about your use case!
Hello again! Following up the discussion at crxjs/chrome-extension-tools#124. I'm now trying to use
@extend-chome/messages
and the built file ends up importing another file like this:This, in turn, throws
Cannot use import statement outside a module
. As you already may know from the linked issue,content-script.ts
was added as an input file inrollup.config.js
. I tried returning an array from rollup config by having a configuration forcontent-script.ts
and another formanifest.ts
and that kind of works butsimpleReloader
is now working right.rollup.config.js looks like this:
Thank you!
The text was updated successfully, but these errors were encountered: