I still learning about how to write chrome extension. I try to import my array of object from myAcc.js to popup.js
but everytime it give me error
Uncaught SyntaxError: Cannot use import statement outside a module
and
Uncaught SyntaxError: Unexpected token 'export'
I have try use module.exports but it didn't work too. is it because chrome extension can't use ES6 import? or I missing something.
popup.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style/style.css">
<title>MEGA.nz Account management</title>
</head>
<body>
<div id='account-box'>
<div class='button-tab-holder'>
<button class='switchBtn'>set1</button>
<button class='switchBtn'>set2</button>
</div>
<div class='account-list1 tab-content show'></div>
<div class='account-list2 tab-content'></div>
</div>
<script type="module" src="./js/popup.js"></script>
</body>
</html>
manifest.json
{
"name": "Account Management",
"version": "1.0",
"description": "Account Manangent for multiple account user",
"manifest_version": 2,
"browser_action": {
"default_title": "Account Management",
"default_popup": "popup.html"
},
"permissions": [
"https://mega.nz/login"
],
"content_scripts": [
{
"matches": ["https://mega.nz/login"],
"css": ["./style/style.css"],
"js": ["./js/popup.js"]
}
]
}
popup.js
import obj_array from "./js/myAcc";
//do stuff
myAcc.js
const accountObj = [{},{},...]
const accountObjSet2 = [{},{},...]
export default obj_array = [accountObj,accountObjSet2]