fixing shim building script
MODIFY
package.json
package.json
{
"name": "ecma-proposal-realms",
"private": true,
- "version": "0.0.0",
+ "version": "1.0.0",
"description": "ECMAScript spec proposal for Realms API",
"scripts": {
"build": "ecmarkup spec/index.emu index.html --css ecmarkup.css --js ecmarkup.js",
"watch": "ecmarkup --watch spec/index.emu index.html --css ecmarkup.css --js ecmarkup.js",
- "build-shim-dev": "node shim/rollup.config.js",
- "build-shim-prod": "node shim/rollup.config.js --production",
+ "build-shim-dev": "cross-env NODE_ENV=development rollup -c shim/rollup.config.js --watch",
+ "build-shim-prod": "cross-env NODE_ENV=production rollup -c shim/rollup.config.js",
"lint": "eslint src/"
},
"repository": {
"type": "git",
- "url": "git+https://github.com/caridy/proposal-realms.git"
+ "url": "git+https://github.com/tc39/proposal-realms.git"
},
"keywords": [
"realms",
},
"license": "MIT",
"bugs": {
- "url": "https://github.com/caridy/proposal-realms/issues"
+ "url": "https://github.com/tc39/proposal-realms/issues"
},
- "homepage": "https://github.com/caridy/proposal-realms#readme",
+ "homepage": "https://github.com/tc39/proposal-realms#readme",
"dependencies": {},
"devDependencies": {
- "ecmarkup": "latest",
"babel-eslint": "^6.1.2",
- "babel-polyfill": "^6.13.0",
- "babel-preset-es2015": "^6.9.0",
- "babel-preset-es2015-rollup": "^1.1.1",
+ "babel-preset-es2015": "^6.22.0",
+ "cross-env": "^3.1.4",
+ "ecmarkup": "latest",
"eslint": "^3.0.1",
"forever": "^0.15.2",
- "rollup": "^0.34.3",
- "rollup-plugin-babel": "^2.6.1",
- "rollup-plugin-commonjs": "^3.3.1",
- "rollup-plugin-inject": "^1.4.1",
- "rollup-plugin-replace": "^1.1.1",
- "rollup-plugin-strip": "^1.1.1",
+ "rollup": "^0.41.3",
+ "rollup-plugin-babel": "^2.7.1",
"rollup-plugin-uglify": "^1.0.1",
- "rollup-watch": "^2.5.0",
- "serve-static": "^1.11.1",
- "watch": "1.0.0",
- "yargs": "^6.0.0"
+ "rollup-watch": "^3.2.2"
}
}

MODIFY
shim/.babelrc
shim/.babelrc
{
"presets": [
- "es2015"
+ ["es2015", { "modules": false }]
]
}

MODIFY
shim/rollup.config.js
shim/rollup.config.js
-/*jshint node: true */
+/* eslint-env node */
+
+/**
+ * This file builds the browser version in shim/dist/ folder.
+ */
'use strict'
-const fs = require('fs');
const path = require('path');
-const argv = require('yargs').argv;
const babel = require('rollup-plugin-babel');
-const commonjs = require('rollup-plugin-commonjs');
const uglify = require('rollup-plugin-uglify');
-const strip = require('rollup-plugin-strip');
-const rollup = require('rollup');
-
-let babelConfig = JSON.parse(fs.readFileSync('shim/.babelrc', 'utf8'));
-babelConfig.babelrc = false;
-babelConfig.presets = babelConfig.presets.map((preset) => {
- return preset === 'es2015' ? 'es2015-rollup' : preset;
-});
-
-const plugins = [
- babel(babelConfig),
- commonjs({
- sourceMap: true
- })
-];
-
-if (argv.production) {
- plugins.push(
- strip({
- debugger: true,
- functions: [ 'console.*', 'assert.*' ],
- })
- );
- plugins.push(
- uglify({
- warnings: false
- })
- );
-}
-function buildBundle(bundleConfig) {
- return rollup.rollup(bundleConfig.input)
- .then(function(bundle) {
- return bundle.write(bundleConfig.output);
- }).then(() => bundleConfig.output.dest);
-}
+const isProduction = process.env.NODE_ENV === 'production';
-const bundleConfig = {
- folder: 'shim/src/',
- input: {
- entry: 'shim/src/main.js',
- plugins: plugins,
- },
- output: {
- dest: 'shim/dist/realm-shim.js',
+module.exports = {
+ entry: path.resolve('shim/src/main.js'),
+ dest: path.resolve('shim/dist/realm-shim.js'),
format: 'umd',
moduleName: 'RealmShim',
sourceMap: true,
- }
+ plugins: [
+ babel(),
+ isProduction && uglify({
+ warnings: false,
+ }),
+ ].filter(Boolean),
};
\ No newline at end of file
-
-if (argv.watch) {
- console.log('watching...');
-
- const watch = require('watch');
- const EventEmitter = require('events');
- const watcher = new EventEmitter();
-
- watch.watchTree(bundleConfig.folder, function onFileChange() {
- buildBundle(bundleConfig)
- .then((dest) => {
- console.log('-> built [%s] bundle', dest);
- watcher.emit('rolled');
- })
- .catch((err) => {
- console.error(err.stack)
- });
- });
-} else {
- console.log('building...');
-
- buildBundle(bundleConfig).catch((err) => {
- console.error(err.stack)
- });
-}

fixing shim building script