JavaScript 模块化工具 rollup.js

    xiaoxiao2023-08-04  140

    rollup.js 详细介绍

    rollup.js 是下一代的 JavaScript 模块化工具,使用 ES2015 模块编写你的应用或者库,可以高效的绑定他们成为单个文件,在浏览器或者 Node.js 中使用,甚至是一些高级特性的绑定,比如 bindings 和 cycles。

    rollup.js 类似 Browserify,生产包比 Browserify 小,或者是跟 Webpack 等价,因为 ES2015 模块比 CommonJS 模块高效。

    代码示例:

    AMD:

    define(function () { 'use strict'; // This function gets included function cube ( x ) { // rewrite this as `square( x ) * x` // and see what happens! return x * x * x; } console.log( cube( 5 ) ); // 125 });

    ES2015:

    // This function gets included function cube ( x ) { // rewrite this as `square( x ) * x` // and see what happens! return x * x * x; } console.log( cube( 5 ) ); // 125

    文章转载自 开源中国社区[https://www.oschina.net]

    相关资源:JavaScript模块化工具rollup.js.zip
    最新回复(0)