Skip to content

Commit

Permalink
Actually build for environments, and make logging cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Mina Smart committed Nov 30, 2017
1 parent 78e63a7 commit 2c7aa78
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 296 deletions.
21 changes: 0 additions & 21 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ test:
- mkdir -p $CIRCLE_TEST_REPORTS/junit
override:
- yarn test
- yarn run test:with-optimized-types
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
"scripts": {
"prepublish": "yarn run build",
"build": "rollup -c",
"start": "yarn run clean && yarn run setup-paths && concurrently 'yarn run test:web-deps' 'yarn run test:livereload-server' 'yarn run test:watch' 'http-server -p 4200 .tmp/test' 'yarn run print-start-message'",
"start": "yarn run clean && yarn run setup-paths && concurrently --names DEPS,LIVERELOAD,ROLLUP,HTTP,NOTIFIER 'yarn run test:web-deps' 'yarn run test:livereload-server' 'yarn run test:watch' 'http-server -p 4200 .tmp/test' 'yarn run print-start-message'",
"clean": "rimraf .tmp index.*",
"doc:build": "jsdoc2md src/*.js > docs/API_REFERENCE.md",
"setup-paths": "mkdir -p .tmp/test",
"test": "yarn run clean && yarn run setup-paths && yarn run test:node-deps && yarn run mocha",
"test:with-optimized-types": "yarn run clean && yarn run setup-paths && yarn run test:node-deps-optimized && yarn run mocha",
"test:watch": "rollup -w -c rollup-browser-tests.config.js",
"test:web-deps": "cp test/index.html node_modules/mocha/mocha.* node_modules/jquery/dist/jquery.slim.min.js .tmp/test/ && cp node_modules/expect.js/index.js .tmp/test/expect.js",
"test:node-deps": "rollup -c rollup-node-tests.config.js",
"test:node-deps-optimized": "cross-env BABEL_ENV='node' node -- scripts/test-build-node.js --with-optimized-types .tmp/test/node-tests.js",
"test:livereload-server": "node scripts/livereload.js",
"test:node-deps": "rollup -c rollup-node-tests.config.js",
"mocha": "mocha -u tdd $(yarn run mocha:reporter-args 2>&1 >/dev/null) .tmp/test/node-tests.js",
"mocha:reporter-args": "test -n \"${CI}\" && >&2 echo --reporter xunit --reporter-options output=$CIRCLE_TEST_REPORTS/junit/mocha-$(date +%s).xml || true",
"lint": "eslint --max-warnings 0 -c .eslintrc.json $(yarn run lint:reporter-args 2>&1 >/dev/null) src/ test/",
Expand All @@ -31,12 +29,10 @@
"dependencies": {},
"devDependencies": {
"babel": "6.23.0",
"babel-cli": "6.26.0",
"babel-core": "6.26.0",
"babel-preset-es2015-rollup": "3.0.0",
"babel-preset-shopify": "15.0.1",
"babel-plugin-external-helpers": "6.22.0",
"babel-preset-env": "1.6.0",
"concurrently": "3.5.0",
"cross-env": "5.0.5",
"eslint": "3.8.1",
"eslint-plugin-shopify": "14.0.0",
"eslint-test-generator": "1.0.5",
Expand All @@ -57,7 +53,7 @@
"rollup": "0.47.6",
"rollup-plugin-babel": "3.0.2",
"rollup-plugin-commonjs": "8.1.0",
"rollup-plugin-graphql-js-client-compiler": "0.1.0",
"rollup-plugin-graphql-js-client-compiler": "0.1.1",
"rollup-plugin-json": "2.3.0",
"rollup-plugin-multi-entry": "2.0.1",
"rollup-plugin-node-builtins": "2.1.2",
Expand Down
20 changes: 15 additions & 5 deletions rollup-browser-tests.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fetch from 'node-fetch';
import graphqlCompiler from 'rollup-plugin-graphql-js-client-compiler';
import nodeResolve from 'rollup-plugin-node-resolve';
import builtins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';
Expand All @@ -10,6 +11,11 @@ const {livereloadPort} = require('./package.json');

const reloadUri = `http://localhost:${livereloadPort}/changed?files=tests.js,index.html`;

baseConfig.plugins.unshift(
graphqlCompiler({
schema: './schema.json'
})
);
baseConfig.plugins.push(
remap({
originalPath: './test/isomorphic-fetch-mock.js',
Expand All @@ -25,11 +31,15 @@ baseConfig.plugins.push(
babel({
babelrc: false,
presets: [
[
`${process.cwd()}/node_modules/babel-preset-shopify/web`, {
modules: false
}
]
[`${process.cwd()}/node_modules/babel-preset-env/lib/index`, {
targets: {
browsers: ['last 2 versions']
},
modules: false
}]
],
plugins: [
`${process.cwd()}/node_modules/babel-plugin-external-helpers/lib/index`
]
}),
{
Expand Down
19 changes: 14 additions & 5 deletions rollup-node-tests.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import graphqlCompiler from 'rollup-plugin-graphql-js-client-compiler';
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import remap from 'rollup-plugin-remap';
import baseConfig from './rollup-tests-common.config';

baseConfig.plugins.unshift(
graphqlCompiler({
schema: './schema.json',
optimize: true,
profileDocuments: ['src/graphql/**/*.graphql']
})
);
baseConfig.plugins.push(
remap({
originalPath: './test/isomorphic-fetch-mock.js',
Expand All @@ -16,11 +24,12 @@ baseConfig.plugins.push(
babel({
babelrc: false,
presets: [
[
`${process.cwd()}/node_modules/babel-preset-shopify/node`, {
modules: false
}
]
[`${process.cwd()}/node_modules/babel-preset-env/lib/index`, {
targets: {
node: '8.1.2'
},
modules: false
}]
]
})
);
Expand Down
4 changes: 0 additions & 4 deletions rollup-tests-common.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import commonjs from 'rollup-plugin-commonjs';
import graphqlCompiler from 'rollup-plugin-graphql-js-client-compiler';
import json from 'rollup-plugin-json';
import multiEntry from 'rollup-plugin-multi-entry';
import eslintTestGenerator from './scripts/rollup-plugin-eslint-test-generator';

export default {
entry: ['test/setup.js', 'test/**/*-test.js'],
plugins: [
graphqlCompiler({
schema: './schema.json'
}),
multiEntry({
exports: false
}),
Expand Down
20 changes: 16 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,22 @@ const plugins = [
jsnext: true,
main: true
}),
babel(),
sizes({
details: true
})
babel({
babelrc: false,
presets: [
[`${process.cwd()}/node_modules/babel-preset-env/lib/index`, {
targets: {
browsers: ['last 2 versions'],
node: '8.1.2'
},
modules: false
}]
],
plugins: [
`${process.cwd()}/node_modules/babel-plugin-external-helpers/lib/index`
]
}),
sizes()
];

const targets = [
Expand Down
7 changes: 7 additions & 0 deletions test/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setup(() => {
if (typeof mocha !== 'undefined') {
mocha.setup({
globals: ['LiveReload']
});
}
});
Loading

0 comments on commit 2c7aa78

Please sign in to comment.