Skip to content

Commit

Permalink
Distribute es5 es2015
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Jan 13, 2017
1 parent 04d4ac1 commit 5984546
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 20 deletions.
2 changes: 0 additions & 2 deletions dist/color-map.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/color-map.js.map

This file was deleted.

22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
"name": "color-map",
"description": "Color map generator",
"version": "0.5.4",
"main": "dist/commonjs/index.js",
"typings": "dist/commonjs/index.d.ts",
"main": "dist/es5/index.js",
"module": "dist/es2015/index.js",
"typings": "dist/es5/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "npm run clean && npm run build-commonjs && npm run build-global",
"build-commonjs": "tsc -p tsconfig.commonjs.json",
"build-global": "rollup --config rollup.config.global.js",
"build": "npm run clean && npm run build-es5 && npm run build-es2015 && npm run build-bundle",
"build-es5": "tsc -p tsconfig.es5.json",
"build-es2015": "tsc -p tsconfig.es2015.json",
"build-bundle": "rollup --config rollup.config.es2015.js && webpack --config webpack.config.es5.js",
"clean": "rimraf dist",
"coverage": "npm test && nyc check-coverage --branches 85 --functions 85 --lines 85",
"coverage": "nyc --check-coverage --branches 85 --functions 85 --lines 85 npm test",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"dependency-check": "dependency-check . --unused --no-dev && dependency-check . --missing --no-dev",
"lint": "tslint \"src/**/*.ts\"",
"postpublish": "git push",
"prepare": "npm run build",
"preversion": "git pull && npm run verify && git add -f dist/color-map*",
"test": "npm run clean && tsc && nyc ava",
"test": "npm run clean && tsc && ava",
"verify": "npm run lint && npm run coverage && npm run build && npm run dependency-check",
"watch": "npm run clean && node scripts/watch.js"
},
Expand Down Expand Up @@ -55,7 +57,7 @@
},
"devDependencies": {
"aurelia-logging": "^1.2.0",
"aurelia-logging-color": "^0.4.1",
"aurelia-logging-color": "^0.4.5",
"aurelia-polyfills": "^1.1.1",
"ava": "^0.17.0",
"browser-env": "^2.0.19",
Expand All @@ -75,8 +77,10 @@
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-sourcemaps": "^0.4.1",
"rollup-plugin-uglify": "^1.0.1",
"source-map-loader": "^0.1.6",
"tslint": "^4.3.1",
"tslint-config-unional": "^0.6.0",
"typescript": "^2.1.5"
"typescript": "^2.1.5",
"webpack": "^2.2.0-rc.4"
}
}
42 changes: 42 additions & 0 deletions rollup.config.es2015.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import paramCase from 'param-case';
import pascalCase from 'pascal-case';
import commonjs from 'rollup-plugin-commonjs';
import nodeBuiltins from 'rollup-plugin-node-builtins';
import nodeGlobals from 'rollup-plugin-node-globals';
import nodeResolve from 'rollup-plugin-node-resolve';
import sourcemaps from 'rollup-plugin-sourcemaps';
// import uglify from 'rollup-plugin-uglify';

const pkg = require('./package');

const moduleName = pascalCase(pkg.name)

export default {
dest: `dist/${paramCase(pkg.name)}.es2015.js`,
entry: 'dist/es2015/index.js',
exports: 'named',
format: 'iife',
moduleId: pkg.name,
moduleName,
// This may comes handy
// onwarn(warning) {
// // Suppress this error message: "The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten"
// // https://github.com/rollup/rollup/issues/794
// if (warning.code === 'THIS_IS_UNDEFINED') {
// return
// }

// console.error(warning.message)
// },
plugins: [
sourcemaps(),
nodeResolve({
jsnext: true
}),
nodeGlobals(),
nodeBuiltins(),
commonjs(),
// uglify()
],
sourceMap: true
};
5 changes: 5 additions & 0 deletions scripts/setup-browser-env.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
require('browser-env')()

// "test": "npm run clean && tsc && ava && export BROWSER_TEST=true; ava",
// if (process.env.BROWSER_TEST) {
// require('browser-env')()
// }
4 changes: 2 additions & 2 deletions scripts/setup-test-env.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('aurelia-polyfills')
const LogManager = require('aurelia-logging')
const ConsoleAppender = require('aurelia-logging-console').ConsoleAppender
const ColorAppender = require('aurelia-logging-color').ColorAppender

LogManager.addAppender(new ConsoleAppender())
LogManager.addAppender(new ColorAppender())

LogManager.setLevel(LogManager.logLevel.debug)
11 changes: 11 additions & 0 deletions tsconfig.es2015.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "dist/es2015",
"sourceRoot": "/color-map",
"target": "es2015"
},
"files": [
"src/index.ts"
]
}
5 changes: 1 addition & 4 deletions tsconfig.commonjs.json → tsconfig.es5.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "dist/commonjs",
"outDir": "dist/es5",
"sourceRoot": "/color-map"
},
"files": [
"src/index.ts"
],
"include": [
"typings/index.d.ts"
]
}
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"buildOnSave": false,
"compileOnSave": false,
"include": [
"src/**/*",
"typings/index.d.ts"
"src/**/*"
]
}
32 changes: 32 additions & 0 deletions webpack.config.es5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';
const paramCase = require('param-case')
const pascalCase = require('pascal-case')
const path = require('path')
const webpack = require('webpack')

const pjson = require('./package.json')

const filename = paramCase(pjson.name)
const globalVariable = pascalCase(filename)

module.exports = {
devtool: 'source-map',
entry: {
[filename]: './dist/es5/index'
},
module: {
rules: [
{
enforce: 'pre',
loader: "source-map-loader",
test: /\.js?$/
}
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: `${filename}.es5.js`,
library: globalVariable,
libraryTarget: 'var'
}
}

0 comments on commit 5984546

Please sign in to comment.