Skip to content

Commit

Permalink
build: adapt building process for only-definition packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Lodin committed Jun 14, 2018
1 parent a59a5a1 commit 7dcd9dd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
21 changes: 18 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
} = require("fs");
const rimraf = require("rimraf");
const {promisify} = require("util");
const packages = require("./project");
const {packages, definitions} = require("./project");

const copyFileAsync = promisify(copyFile);
const execAsync = promisify(exec);
Expand Down Expand Up @@ -74,20 +74,35 @@ const copyDtsFiles = async (pack) => {
);
};

const buildCommon = async pack => Promise.all([
copyProjectFiles(pack),
copyDtsFiles(pack),
]);

const build = async (pack) => {
await recreateDist(pack);

await Promise.all([
execAsync(`rollup -c scripts/rollup.config.js`),
copyProjectFiles(pack),
copyDtsFiles(pack),
buildCommon(pack),
]);

await execAsync(`cd ${root(pack, "dist")} && npm pack`);

console.log(`✓ "${pack}" is built`);
};

const buildDefinitions = async (pack) => {
await recreateDist(pack);
await buildCommon(pack);
await execAsync(`cd ${root(pack, "dist")} && npm pack`);
console.log(`✓ "${pack}" is built`);
};

for (const pack of Object.keys(packages)) {
build(pack);
}

for (const pack of definitions) {
buildDefinitions(pack);
}
7 changes: 6 additions & 1 deletion scripts/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ const packages = {
],
};

module.exports = packages;
const definitions = ["types"];

module.exports = {
definitions,
packages,
};
2 changes: 1 addition & 1 deletion scripts/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const packages = require("./project");
const {packages} = require("./project");

module.exports = Object.entries(packages).reduce((acc, [pack, entries]) => {
for (const file of entries) {
Expand Down

0 comments on commit 7dcd9dd

Please sign in to comment.