0

I am trying to export and import objects in the browser using ES6 modules.

I have tried

import { options } from 'options';

but I get the error Uncaught SyntaxError: Unexpected token import.

Then I tried transpiling it, but now I receive the error Uncaught ReferenceError: require is not defined.

Is it not possible to use modules in the browser?

Jamgreen
  • 8,491
  • 24
  • 79
  • 186
  • You need webpack or browserify or something that bundles for the browser. – sdgluck Oct 14 '16 at 12:25
  • I am using `babel-standalone` to transpile it. Shouldn't it work like webpack and browserify? – Jamgreen Oct 14 '16 at 12:32
  • ES6 Modules are not implemented yet... [https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/import](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/import) – fistuks Oct 14 '16 at 12:41
  • The future is soon: http://caniuse.com/#search=modules – robertwbradford Apr 17 '17 at 22:06

1 Answers1

0

You might want to look into http://jspm.io/ it's based on system.js.

Hope that helps..

Keith
  • 15,057
  • 1
  • 18
  • 31