Issue: In Chrome 63, importing ES6 modules using the import/export syntax in a content script results in syntax errors.
Solution:
Chrome extensions support ES6 modules through an asynchronous dynamic import() function:
(async () => { const src = chrome.runtime.getURL("your/content_main.js"); const contentMain = await import(src); contentMain.main(); })();
However, this method has limitations:
For non-module scripts, consider:
Additional Information:
The above is the detailed content of How Can I Successfully Import ES6 Modules into My Chrome Extension\'s Content Scripts?. For more information, please follow other related articles on the PHP Chinese website!