Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use "import" in public/app/background.js file #36

Closed
kehtolaulu opened this issue Jul 16, 2020 · 1 comment
Closed

Can't use "import" in public/app/background.js file #36

kehtolaulu opened this issue Jul 16, 2020 · 1 comment

Comments

@kehtolaulu
Copy link

kehtolaulu commented Jul 16, 2020

Hello!
I want to import some functions from other files. src files are built ok, so I can use import in them, but I can't do it in my background.js file.
Uncaught SyntaxError: Cannot use import statement outside a module
Could you help me?

@satendra02
Copy link
Owner

Hi @kehtolaulu,

You can't import your src folder functions inside background.js. It is used by extension as background script.

You must use Chrome messaging API to send and receive data.
I already used it in background.js to send message when user click extension icon and then received it in content.js to toggle the extension. Similarly you can send message to background.js from src folder.

Let me know if you need more help. Also if you haven't read this article then go through it. Here I have explained in detail how things are working in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants