diff --git a/.babelrc b/.babelrc index 3f89d16..db84814 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,4 @@ { - "presets": ["@babel/preset-env"], "plugins": [ "@babel/plugin-proposal-class-properties" ] diff --git a/.gitignore b/.gitignore index 5cdf045..429fa15 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/pkg /dist /node_modules /yarn.lock diff --git a/index.js b/index.js deleted file mode 100644 index 11fe17f..0000000 --- a/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./src/union"; \ No newline at end of file diff --git a/package.json b/package.json index fd5401e..826d31b 100644 --- a/package.json +++ b/package.json @@ -6,33 +6,46 @@ "author": "Charles Lowell ", "license": "MIT", "private": false, - "main": "dist/microtates-union.cjs.js", - "module": "dist/microtates-union.es.js", - "unpkg": "dist/microtates-union.umd.js", - "browser": "dist/microtates-union.umd.js", "scripts": { "test": "mocha --recursive -r tests/setup tests", - "build": "rollup -c", - "prepare": "npm run build", - "prerelease": "npm test && npm run build" + "build": "pack build", + "prepare": "yarn build", + "publish": "pack publish", + "prepublishOnly": "yarn test && yarn build" }, "devDependencies": { "@babel/core": "^7.1.6", "@babel/plugin-proposal-class-properties": "^7.1.0", "@babel/preset-env": "^7.0.0", "@babel/register": "^7.0.0", + "@pika/pack": "^0.3.5", + "@pika/plugin-build-node": "^0.3.14", + "@pika/plugin-build-web": "^0.3.14", + "@pika/plugin-standard-pkg": "0.3.14", "babel-eslint": "^10.0.1", "expect": "^24.1.0", - "mocha": "^5.2.0", - "rollup": "^1.0.0", - "rollup-plugin-babel": "4.3.1", - "rollup-plugin-commonjs": "9.2.0", - "rollup-plugin-filesize": "6.0.0", - "rollup-plugin-node-resolve": "4.0.0", - "rollup-plugin-replace": "2.1.0", - "microstates": "^0.13.0" + "microstates": "^0.13.0", + "mocha": "^5.2.0" }, "peerDependencies": { "microstates": "^0.13.0" + }, + "@pika/pack": { + "pipeline": [ + [ + "@pika/plugin-standard-pkg", + { + "exclude": [ + "__tests__/**/*" + ] + } + ], + [ + "@pika/plugin-build-node" + ], + [ + "@pika/plugin-build-web" + ] + ] } } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index a6b9dfd..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,109 +0,0 @@ -const pkg = require("./package.json"); -const babel = require("rollup-plugin-babel"); -const filesize = require("rollup-plugin-filesize"); -const resolve = require("rollup-plugin-node-resolve"); -const commonjs = require('rollup-plugin-commonjs'); -const replace = require('rollup-plugin-replace'); - -const external = [ - "microstates" -]; - -const globals = { - "microstates": "Microstates" -} - -const babelPlugin = babel({ - babelrc: false, - comments: false, - plugins: ["@babel/plugin-proposal-class-properties"], - presets: [ - [ - "@babel/preset-env", - { - modules: false - } - ] - ] -}); - -const fileSize = filesize(); - -module.exports = [ - { - input: "index.js", - output: { - name: 'MicrostatesUnion', - file: pkg.unpkg, - format: "umd", - globals - }, - external, - plugins: [ - replace({ - "process.env.NODE_ENV": JSON.stringify('production') - }), - resolve({ - module: false, - main: true - }), - babel({ - babelrc: false, - comments: false, - plugins: ["@babel/plugin-proposal-class-properties"], - presets: [ - [ - "@babel/preset-env", - { - targets: { - chrome: "58", - }, - modules: false - } - ] - ] - }), - commonjs(), - fileSize - ] - }, - { - input: "index.js", - external, - output: { - file: pkg.main, - format: "cjs", - sourcemap: true - }, - plugins: [ - resolve(), - babel({ - babelrc: false, - comments: false, - plugins: ["@babel/plugin-proposal-class-properties"], - presets: [ - [ - "@babel/preset-env", - { - targets: { - node: "6" - }, - modules: false - } - ] - ] - }), - fileSize - ] - }, - { - input: "index.js", - external, - output: { file: pkg.module, format: "es", sourcemap: true }, - plugins: [ - resolve(), - babelPlugin, - fileSize - ] - } -]; \ No newline at end of file diff --git a/src/union.js b/src/index.js similarity index 97% rename from src/union.js rename to src/index.js index 6d5298d..bc83102 100644 --- a/src/union.js +++ b/src/index.js @@ -1,6 +1,4 @@ -import * as M from 'microstates'; - -const { create, valueOf } = M; +import { create, valueOf } from 'microstates'; export default function Union(members, Base = class {}) { let types = Object.keys(members); diff --git a/tests/index.test.js b/tests/index.test.js deleted file mode 100644 index a80177c..0000000 --- a/tests/index.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import Union from '../index'; - -import expect from 'expect'; - -describe('index.js', ()=> { - it('has the Union function as its default export', ()=> { - expect(Union).toBeInstanceOf(Function); - }); -}); diff --git a/tests/setup b/tests/setup index bdf5681..fdeaf4f 100644 --- a/tests/setup +++ b/tests/setup @@ -4,6 +4,7 @@ require("@babel/register")({ // This will override `node_modules` ignoring - you can alternatively pass // an array of strings to be explicitly matched or a regex / glob ignore: ['node_modules/*'], + presets: ['@babel/preset-env'], plugins: [ '@babel/plugin-proposal-class-properties' ] diff --git a/tests/union.test.js b/tests/union.test.js index 3cdaa7f..158b0a1 100644 --- a/tests/union.test.js +++ b/tests/union.test.js @@ -1,6 +1,6 @@ import expect from 'expect'; -import Union from '../src/union'; +import Union from '../src'; import { create } from 'microstates'; describe('Using a union type to construct a Maybe value', ()=> {