[Javascript] An Introduction to JSPM (JavaScript Package Manager)
JSPM can handle installed packages, transpiling ES6, and bundling all from the command-line. This video gives a quick overview of install JSPM, installing packages with JSPM, writing a very simple app in ES6 that uses those packages, then bundling up for production.
Install:
npm install jspm -g
You can use jspm to install any package:
jspm install --save lodash moment
This will help you to create package.json and you need to select some default options such as transplier: Babel.
We create index.html, to import system.js and config.js files whcih created by jspm. Then use System.js to import the app.js file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="./jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app');
</script>
</head>
<body> </body>
</html>
app.js:
import moment from 'moment';
import _ from 'lodash'; let date = moment().format(); _.forEach(date, char => console.log(char));
In the file we can use ES6 already.
Then when you open the index.html you will see it works.
RUN:
jspm bundle-sfx --minify app
This will create a build.js file,
Replace html with:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="build.js"></script>
</head>
<body> </body>
</html>
Only includes new build.js file, u will see everything still works.
[Javascript] An Introduction to JSPM (JavaScript Package Manager)的更多相关文章
- [Yarn] A JavaScript Package Manager
Yarn is a new JavaScript package manager that aims to be speedy, deterministic, and secure. See how ...
- Introduction to Object-Oriented JavaScript 转载自:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript
Introduction to Object-Oriented JavaScript IN THIS ARTICLE JavaScript review Object-oriented program ...
- 你需要知道的包管理器(Package Manager)
最近我花了一点时间关注了在不同系统之中所用到的包管理器(Package Manager) .最开始的时候,我是在使用Linux操作系统时,对这种工具以及它背后的想法深深迷恋住了:这真是自由的软件世界. ...
- A package manager for Qt
官网 http://www.qpm.io/ A package manager for Qt 注释:这个网站类似JavaScript的包管理器的网站https://www.npmjs.com/ 都是给 ...
- 前端笔记知识点整合之JavaScript(一)初识JavaScript
一.JavaScript简介 1.1网页分层 web前端一共分三层: 结构层 HTML : 负责搭建页面结构 样式层 CSS : 负责页面的美观 行为层 JavaSc ...
- 前端笔记之JavaScript(一)初识JavaScript
一.JavaScript简介 1.1网页分层 web前端一共分三层: 结构层 HTML : 负责搭建页面结构 样式层 CSS : 负责页面的美观 行为层 JavaSc ...
- href="javascript:xxx(this);"和onclick="javascript:xxx(this);"的区别
href="javascript:xxx(this);"和onclick="javascript:xxx(this);" 一直以为这两种写法是等同的,今天在项目 ...
- 解决VS2015启动时Package manager console崩溃的问题 - Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope
安装VS2015,启动以后,Package manager console崩溃,错误信息如下: Windows PowerShell updated your execution policy suc ...
- Visual Studio 2015 新建MVC项目 Package Manager Console不能使用 (HRESULT: 0x80131500)
Visual studio 2015 突然新建不了MVC项目,报出错误: HRESULT: 0x80131500 在折腾了很长时间,最后在Github上看到这样一个贴 地址:https://githu ...
随机推荐
- 1.document.write(""); 输出语句
1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4. ...
- 编程框架—Autofac
Autofac是一款轻量级的IOC框架,性能高. Autofac基本使用步骤: 1.创建容器建造者(Builder): 2.对Builder注册类型. 3.Buildder创建容器(Container ...
- Objective-C 入门(给新人的)
http://www.hengxinsoft.com/2010/12/objective-c-%E5%85%A5%E9%97%A8%EF%BC%88%E7%BB%99%E6%96%B0%E4%BA%B ...
- 用Org-Mode和Jekll写博客
该文章同时发布在我的github blog上:http://cheukyin.github.io/jekyll/emacs/2014-08/org2jekyll.html 1 前言 在这个月之前,我一 ...
- applicationContext.xml详解 spring+mybatis+struts
今天给大家详细解释一项关于Spring的applicationContext.xml文件,这对于初学者来说,应该是很有帮助的, 以下是详解Spring的applicationContext.xml文件 ...
- HashMap遍历,推荐使用entrySet()
之前map遍历,偶尔会先去keyset然后再遍历keyset 比如 Map map = new HashMap(); Iterator it = map.keySet().iterator(); wh ...
- CSS user-select属性拾遗
昨天把Notebook整理了一下,去查了一下手册,原来之前比较忽略user-select这个属性,因为之前以为只有webkit才支持的.手册进行了补充: user-select 禁止用户选中文字 no ...
- bzoj 2209: [Jsoi2011]括号序列 splay
2209: [Jsoi2011]括号序列 Time Limit: 20 Sec Memory Limit: 259 MBSubmit: 833 Solved: 392[Submit][Status ...
- Cyclic Tour HDUOJ 费用流
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Others)Total ...
- golang入门--一个简单的http client
看完<Go Web 编程>的前两章就可以开始写代码了. import ( "fmt" "io/ioutil" "log" &qu ...