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
Hi,
I'm building a chrome extension with react ts and vite. I have two entry points for my content and background scripts. Both of them share a single types file which is present in the root directory. This is my vite configuration:
The generated build has types in a separate directory like this:
Both the bundled background and content scripts are importing types form this directory. Because of this my extension is not working as it throws error saying 'import statement cannot be used outside a module'.
How to bundle the types along with the javascript bundle?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm building a chrome extension with react ts and vite. I have two entry points for my content and background scripts. Both of them share a single types file which is present in the root directory. This is my vite configuration:
And this is my directory structure:

The generated build has types in a separate directory like this:

Both the bundled background and content scripts are importing types form this directory. Because of this my extension is not working as it throws error saying 'import statement cannot be used outside a module'.
How to bundle the types along with the javascript bundle?
Beta Was this translation helpful? Give feedback.
All reactions