Skip to content

Instantly share code, notes, and snippets.

@riccardoscalco
Last active May 26, 2016 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riccardoscalco/3c7fbaca1e9543bc1d50 to your computer and use it in GitHub Desktop.
Save riccardoscalco/3c7fbaca1e9543bc1d50 to your computer and use it in GitHub Desktop.
JSPM tutorial

Resources


Set node version

$ nvm install 5.7.0

Create a new proj

$ mkdir myproj
$ cd myproj
$ sudo npm install jspm --save-dev

Initialise jspm

$ jspm init -y
$ node_modules/.bin/jspm init -y

Run through the prompts again

$ jspm init -p

Reinstall dependencies

$ jspm install

Add Eslint Dependences

$ sudo npm install --save-dev eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint

Create an html file index.html on the root dir

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible” content=”IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
   </head>
   <body>
     <script src="jspm_packages/system.js"></script>
     <script src="config.js"></script>
     <script>
       System.import('main.js')
     </script>
   </body>
</html>

Create a main.js file on the root dir

console.log('is this thing on?');

Lauch the live server

$ live-server --no-browser --port=8000

Bundle

$ jspm bundle main --inject

Install External Dependencies

$ jspm install package-name
$ jspm uninstall package-name

For an es6 REPL, try http://jsoverson.github.io/es6repl, or

$ npm install --save-dev babel-cli
$ npm install babel-preset-es2015 
$ ./node_modules/.bin/babel-node --presets es2015
$ let myModule = require('./lib/mymodule.js')

Note that module imported inside js files must be npm installed, for example:

$ npm install d3

Intall local modules (dopo npm init dentro la cartella del file js)

$ ./node_modules/.bin/jspm uninstall local:ui/app/external/FEB/package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment