Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use JSPM without a transpiler?

Tags:

jspm

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.

like image 767
Greg Gum Avatar asked Sep 08 '15 21:09

Greg Gum


1 Answers

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:[email protected] (from map field) which when combined with the path field refers to jspm_packages/npm/[email protected] 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".

like image 79
caasjj Avatar answered Sep 28 '22 02:09

caasjj