Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/272 es6 pkg module #275

Merged
merged 7 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import webpack from 'webpack';
import webpackStream from 'webpack-stream';

import _ from 'underscore';
import rollup from 'rollup';
import {rollup} from 'rollup';
import babel from 'rollup-plugin-babel';
import preset from 'babel-preset-es2015-rollup';
import fs from 'fs';
Expand Down Expand Up @@ -68,9 +68,23 @@ function getBanner() {
return _.template(banner)(manifest);
}

function buildESModule(bundle) {
return bundle.write({
format: 'es',
dest: manifest.module,
sourceMap: true,
banner: getBanner()
}).then(function(gen) {
return gen;
}).catch(function(error) {
console.log(error);
});
}

function build(done) {
rollup.rollup({
rollup({
entry: path.join('src', config.entryFileName),
external: ['underscore', 'backbone'],
plugins: [
babel({
sourceMaps: true,
Expand All @@ -79,12 +93,15 @@ function build(done) {
})
]
}).then(function(bundle) {
var banner = getBanner();

buildESModule(bundle);
var result = bundle.generate({
banner: banner,
banner: getBanner(),
format: 'umd',
sourceMap: 'inline',
globals: {
underscore: '_',
backbone: 'Backbone'
},
sourceMapSource: config.entryFileName + '.js',
sourceMapFile: exportFileName + '.js',
moduleName: config.mainVarName
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"homepage": "https://github.com/marionettejs/backbone.radio",
"version": "2.0.0",
"main": "build/backbone.radio.js",
"module": "build/backbone.radio.esm.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file need to be checked into the source tree or is it automatically generated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, I should have added the module and source map to git

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's wired into the build so would get generated with the rest of the files in build/ in the future.

I'm not sure what needs to be done, if anything for the NPM package to include the ES modules.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The es build must be in the package distributed.

Commit in the repository is optional. Anyway if deciding to commit to repository, It should be done only just before a release.

"keywords": [
"backbone",
"marionette",
Expand Down Expand Up @@ -45,13 +46,13 @@
"underscore": "^1.8.3"
},
"devDependencies": {
"babel-core": "6.7.0",
"babel-eslint": "6.0.4",
"babel-core": "6.24.0",
"babel-eslint": "7.0.0",
"babel-loader": "6.2.0",
"babel-polyfill": "6.6.1",
"babel-preset-es2015": "6.3.13",
"babel-preset-es2015-rollup": "1.1.1",
"babel-register": "6.4.3",
"babel-polyfill": "6.23.0",
"babel-preset-es2015": "6.24.0",
"babel-preset-es2015-rollup": "3.0.0",
"babel-register": "6.24.0",
"backbone": ">=1.3.3 <1.4.0",
"chai": "3.4.1",
"del": "2.2.0",
Expand All @@ -76,8 +77,8 @@
"json-loader": "0.5.3",
"mkdirp": "0.5.1",
"mocha": "2.3.4",
"rollup": "0.25.4",
"rollup-plugin-babel": "2.4.0",
"rollup": "0.36.3",
"rollup-plugin-babel": "2.6.1",
"sinon": "1.17.2",
"sinon-chai": "2.8.0",
"underscore": "1.8.3",
Expand Down