13

I am using jspm 0.16.2.

I am using this test project

When I set the Transpiler to none: transpiler: "none"

I get an error XHR error (404 Not Found) loading http://localhost:53404/none.js

If I set the transpiler to 'test' it gives the same error, except for it looks for test.js

Is this a bug with jspm?

I wanted to not use a transpiler, but use system.js to load AMD modules.

When I removed the transpiler option from config.js, then it tries to load Traceur.

I would like to not have a Transpiler running at runtime.

Greg Gum
  • 33,478
  • 39
  • 162
  • 233

1 Answers1

8

It's not clear what you're trying to do. If you use ES2015 features (e.g. ES2015 modules, let, etc.), then you need the transpiler. If you write your code with no ES2015 features, then no transpiler will be loaded. You can check this by putting ES5 code in main.js and checking the Network tab of your debugger. browser.js will not be downloaded.

The string you put in for transpiler in System.config is literally the transpiler file itself. In the case of "babel", it is mapped to npm:babel-core@5.8.3 (from map field) which when combined with the path field refers to jspm_packages/npm/babel-core@5.8.3 and then in that directory, the file .jspm.json points the entry point to browser.js, which is the client side transpiler file itself.

Whatever string you set transpiler to, jspm will set up System to point to it (the path will just be the baseURL if you haven't mapped it) and fetch it. Of course it's not there for any arbitrary string such as none or test. The default, if you don't specify anything, as you've observed is traceur.

You do have the option of transpiling server side by doing jspm bundle if client side transipling is what you're trying to avoid.

For code that uses only ES5 and AMD, without transpiling, checkout the no-transpile branch of the above repo. Note that browser.js is not downloaded even though transpile is still set to "babel".

caasjj
  • 1,354
  • 8
  • 11
  • +1 for the detailed information. I think I understand now what the situation. I think what mislead me is that you can answer "No" to the Transpiler question when running jspm init, and it will insert "none" in config.js for the transpiler. – Greg Gum Sep 09 '15 at 16:31
  • 1
    Yes, but then if your code has ES2015 features in it, `System` *will* try to transpile it anyway - with the `none` transpiler. The safe thing to do, if you want to make certain there is no transpilation, is to set that field to any invalid string (such as `none`) and then write your code with straight ES5. That way, you'll error out if any ES2015 code sneaks in, e.g. via some module you imported. – caasjj Sep 09 '15 at 16:42
  • OK, I get it now. Thanks very much. – Greg Gum Sep 09 '15 at 18:47
  • 1
    Why bundle doesn't transpile code during bundling, so we can use es6 and no transpiler in the browser? – rofrol Sep 17 '15 at 16:48
  • @rofrol Sure it does. See my updated instructions in the `master` branch of the test project repo OP mentions. – caasjj Sep 17 '15 at 17:12
  • Your instructions mention es5. I want to use es6, transpile it during bundling and don't load tracer into the browser – rofrol Sep 17 '15 at 17:31
  • 1
    Please look at the repo 'master' branch more carefully. 'main.js' is an ES6 module. If you follow the exact instructions, you will get a single transpired 'bundle.js' downloaded to the browser and no transpiler downloaded. – caasjj Sep 17 '15 at 17:34
  • Hi @caasjj, your repo cleared a lot of things up for me with regard to transpiling and jspm builds, thank you. I noticed that when I try and asynchronously load a module in the main bundle, the ES6 module is effectively fetched with `System.import()`. This must mean that some transpiling capabilities are included. Also, is there a method by which I can async load ES5 modules with System.import? Explained in detail here: http://stackoverflow.com/questions/36018965/using-jspm-to-load-async-es5-modules-in-production – Himmel Mar 15 '16 at 18:25