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

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

Open

Description

@tomasvarg

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?

Activity

  1. guybedford commented on Sep 18, 2017

    @guybedford
    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.

  2. tomasvarg commented on Sep 19, 2017

    @tomasvarg
    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.)

  3. guybedford commented on Sep 20, 2017

    @guybedford
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions