Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

The plugin doesn't seem to be doing anything #84

Open
tomasvarg opened this issue Sep 13, 2017 · 3 comments
Open

The plugin doesn't seem to be doing anything #84

tomasvarg opened this issue Sep 13, 2017 · 3 comments

Comments

@tomasvarg
Copy link

tomasvarg commented Sep 13, 2017

I'm not able to run anything needing transpilation even with the most basic configuration - attempt to run something ends with syntax error on node_modules/systemjs/dist/system.src.js:2823:8; when I try to log source param of the getSource function on this line I'm getting untranspiled code.

index.html (only the relevant part):

    <script src="node_modules/promise-polyfill/promise.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="system.config.js"></script>
    <script>
      SystemJS.import('index.js');
    </script>

system.config.js:

SystemJS.config({
    map: {
        'plugin-babel': 'node_modules/systemjs-plugin-babel/plugin-babel.js',
        'systemjs-babel-build': 'node_modules/systemjs-plugin-babel/systemjs-babel-browser.js'
    },
    transpiler: 'plugin-babel'
});

(Adding baseURL, defaultJSExtension won't help)

index.js

setTimeout(() => {
    console.log('Hello from es6!');
}, 0);

Exact stack trace:

SyntaxError: Wrong syntax
   at evaluate (http://10.0.0.13:8081/node_modules/systemjs/dist/system.src.js:2823:8)
   at Anonymous function (http://10.0.0.13:8081/node_modules/systemjs/dist/system.src.js:3626:11)
   at dynamicExecute (http://10.0.0.13:8081/node_modules/systemjs/dist/system.src.js:1145:5)
   at doEvaluate (http://10.0.0.13:8081/node_modules/systemjs/dist/system.src.js:1092:7)
   at ensureEvaluate (http://10.0.0.13:8081/node_modules/systemjs/dist/system.src.js:1000:3)
   at Anonymous function (http://10.0.0.13:8081/node_modules/systemjs/dist/system.src.js:613:7)
   at Anonymous function (http://10.0.0.13:8081/node_modules/promise-polyfill/promise.js:44:9)

versions (apart from promise-polyfill no other packages present):

    "systemjs": "^0.20.18",
    "systemjs-plugin-babel": "0.0.25"

(Don't have any other old browser than IE11, sorry. Also tried to include various core-js polyfills.)

Am I missing something obvious?

@guybedford
Copy link
Member

By default SystemJS won't transpile all code, only code it deems to be ES module code.

Try adding:

System.config({
  meta: {
    'path-to-index-dir/*': { format: 'esm' }
  }
});

Or just specifically for the index.js even.

@tomasvarg
Copy link
Author

This works, thanks!

Do I get it right that's what the following note in systemjs/doc/module-format.md states?

Note that ES6 modules are detected via the presence of import and export module syntax and no other features at all. This is because the transpilation applies to the module format specifically, not the language.

(I thought about adding a feature detection clarification in the plugin's readme.)

@guybedford
Copy link
Member

Yes exactly, if you'd like to clarify PR's welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants