ModuleLoader / es-module-loader

Polyfill for the ES Module Loader
MIT License
2.23k stars 185 forks source link

Uncaught (in promise) Error: ES6 transpilation is only provided in the dev module loader build. #430

Closed es6Test closed 9 years ago

es6Test commented 9 years ago

I am getting this error when I run my webapp:

Uncaught (in promise) Error: ES6 transpilation is only provided in the dev module loader build.

I am trying to use the module loader like so:

  <script src="node_modules/es6-module-loader/dist/es6-module-loader.js"></script>
  <script src="node_modules/babel-core/browser.min.js"></script>
  <script src="node_modules/object.observe/dist/object-observe-lite.js"></script>
  <link rel="stylesheet" href="main.css">
  <script>
    System.transpiler = 'babel';
    System.import('app/main.js').then(function (module) {
      new module.Main();
    });

  </script>

main.js


import foo from './foo'

export class Main {
  constructor() {
    let cart;
    let items = localStorage.getItem("items");

}

I have the following dependencies

{
  "devDependencies": {
    "babel-core": "^5.8.22",
    "es6-module-loader": "^0.17.6",
    "object.observe": "^0.2.4",
    "qunitjs": "^1.18.0"
  }
}

Any ideas?

jnsq commented 9 years ago

Try loading es6-module-loader-dev.js file instead of es6-module-loader.js.

es6Test commented 9 years ago

thanks but now I get:

`Failed to load resource: the server responded with a status of 404 (Not Found) index.html:1 Uncaught (in promise) Error: XHR error (404 Not Found) loading http://localhost:63342/foo )```

however it does resolve if

import foo from './foo.js'

instead of

import foo from './foo'

is this expected with es6?

jnsq commented 9 years ago

I couldn't get rid of errors using es6-module-loader, but using babel (with gulp) + browserify, i can import files without adding the extension (maybe it's due to babel converting "import" to "require" in common js).

But as far as i remember, the last spec concerning es6 modules say that we have to include the extension to import / System.import js files.