1

This issue appears in Firefox Developer Edition 53.0a2.

This take place in context of WebExtension development.

I have a lib script that export a simple variable.

my-lib.js

export const foo = 42

my-background-script.js

import foo from 'my-lib'

// ...

This throws a SyntaxError: import declarations may only appear at top level of a module

How can I import variables or functions declared in different javascript files ?

1 Answer 1

2

ES6 modules support is not far enough yet (source MDN)

The use of Webpack or Babel is the option to transpile the code to a compatible javascript version.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.