Skip to content

Commit

Permalink
transpile src to multi targets (#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Jan 13, 2020
1 parent 7d3a9a8 commit 1553f9a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
20 changes: 13 additions & 7 deletions packages/subapp-web/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
module.exports = {
presets: [
["@babel/env", { modules: "auto" }],
"@babel/react",
process.env.MINIFY ? "minify" : undefined
].filter(x => x)
};
const envOpts = { modules: "auto" };

if (process.env.BABEL_ENV === "src-node") {
Object.assign(envOpts, { targets: { node: "10" } });
}

const presets = [["@babel/env", envOpts], "@babel/react"];

if (process.env.MINIFY) {
presets.push("minify");
}

module.exports = { presets };
1 change: 1 addition & 0 deletions packages/subapp-web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
browser
dist
*-lock.*
node-dist
2 changes: 1 addition & 1 deletion packages/subapp-web/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const { registerSubApp } = require("subapp-util");

const { default: makeSubAppSpec } = require("../browser/make-subapp-spec");
const { default: makeSubAppSpec } = require("../node-dist/make-subapp-spec");

const { setupFramework } = require("./util");

Expand Down
11 changes: 6 additions & 5 deletions packages/subapp-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"browser": "browser/index.js",
"main": "lib/index.js",
"scripts": {
"test": "clap check",
"coverage": "clap check",
"build": "clap -x -n compile minify",
"compile": "babel src -d browser --source-maps"
"test": "clap -x compile check",
"coverage": "clap -x compile check",
"build": "clap compile",
"prepublishOnly": "clap compile"
},
"keywords": [
"web",
Expand All @@ -23,7 +23,8 @@
"files": [
"lib",
"browser",
"dist"
"dist",
"node-dist"
],
"dependencies": {
"history": "^4.9.0",
Expand Down
14 changes: 12 additions & 2 deletions packages/subapp-web/xclap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
const xclap = require("xclap");
const { env, exec, concurrent } = xclap;

xclap.load({
minify: xclap.exec("babel src -d dist --source-maps", {
execOptions: { env: { MINIFY: "true" } }
compile: concurrent("compile-browser", "compile-dist", "compile-node"),
"compile-browser": exec("babel src -d browser --delete-dir-on-start --source-maps", {
env: { BABEL_ENV: "src-browser" }
}),
"compile-dist": exec("babel src -d dist --delete-dir-on-start --source-maps", {
env: { MINIFY: "true", BABEL_ENV: "src-dist" }
}),
"compile-node": exec("babel src -d node-dist --delete-dir-on-start --source-maps", {
env: { BABEL_ENV: "src-node" }
})
});

require("electrode-archetype-njs-module-dev")();

0 comments on commit 1553f9a

Please sign in to comment.