Skip to content

Commit

Permalink
fix: publish should build without cache (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle authored Apr 28, 2021
1 parent ac78bcd commit 3d2ae6f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"dist"
],
"scripts": {
"build": "node scripts/build",
"build": "node scripts/build.js",
"build-test-binary": "cd test/binary && node-gyp rebuild && cp build/Release/hello.node ../integration/hello.node",
"codecov": "codecov",
"test": "node --expose-gc --max_old_space_size=3072 node_modules/.bin/jest",
"test-coverage": "node --expose-gc --max_old_space_size=3072 node_modules/.bin/jest --coverage --globals \"{\\\"coverage\\\":true}\" && codecov",
"prepublish": "in-publish && npm test || not-in-publish"
"prepublishOnly": "node scripts/build.js --no-cache"
},
"devDependencies": {
"@azure/cosmos": "^2.0.5",
Expand Down Expand Up @@ -59,7 +59,6 @@
"graphql": "^14.0.2",
"highlights": "^3.1.1",
"hot-shots": "^5.9.2",
"in-publish": "^2.0.0",
"ioredis": "^4.2.0",
"isomorphic-unfetch": "^3.0.0",
"jest": "^26.3.0",
Expand Down
19 changes: 12 additions & 7 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const ncc = require("../src/index.js");
const { statSync, writeFileSync, readFileSync, unlinkSync } = require("fs");
const { promisify } = require("util");
const { relative } = require("path");
const { relative, join } = require("path");
const copy = promisify(require("copy"));
const glob = promisify(require("glob"));
const bytes = require("bytes");

const minify = true;
const v8cache = true;
const cache = process.argv[2] === "--no-cache" ? false : join(__dirname, "..", ".cache");

async function main() {
for (const file of await glob(__dirname + "/../dist/**/*.@(js|cache|ts)")) {
Expand All @@ -20,7 +22,8 @@ async function main() {
externals: ["./index.js"],
license: 'LICENSES.txt',
minify,
v8cache: true
cache,
v8cache
}
);
checkUnknownAssets('cli', Object.keys(cliAssets));
Expand All @@ -30,7 +33,8 @@ async function main() {
{
filename: "index.js",
minify,
v8cache: true
cache,
v8cache
}
);
checkUnknownAssets('index', Object.keys(indexAssets).filter(asset =>
Expand All @@ -39,13 +43,13 @@ async function main() {

const { code: relocateLoader, assets: relocateLoaderAssets } = await ncc(
__dirname + "/../src/loaders/relocate-loader",
{ filename: "relocate-loader.js", minify, v8cache: true }
{ filename: "relocate-loader.js", minify, cache, v8cache }
);
checkUnknownAssets('relocate-loader', Object.keys(relocateLoaderAssets));

const { code: shebangLoader, assets: shebangLoaderAssets } = await ncc(
__dirname + "/../src/loaders/shebang-loader",
{ filename: "shebang-loader.js", minify, v8cache: true }
{ filename: "shebang-loader.js", minify, cache, v8cache }
);
checkUnknownAssets('shebang-loader', Object.keys(shebangLoaderAssets));

Expand All @@ -54,15 +58,16 @@ async function main() {
{
filename: "ts-loader.js",
minify,
v8cache: true,
cache,
v8cache,
noAssetBuilds: true
},
);
checkUnknownAssets('ts-loader', Object.keys(tsLoaderAssets).filter(asset => !asset.startsWith('lib/') && !asset.startsWith('typescript/lib')));

const { code: sourcemapSupport, assets: sourcemapAssets } = await ncc(
require.resolve("source-map-support/register"),
{ filename: "sourcemap-register.js", minify, v8cache: true }
{ filename: "sourcemap-register.js", minify, cache, v8cache }
);
checkUnknownAssets('source-map-support/register', Object.keys(sourcemapAssets));

Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7202,11 +7202,6 @@ imurmurhash@^0.1.4:
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=

in-publish@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/in-publish/-/in-publish-2.0.1.tgz#948b1a535c8030561cea522f73f78f4be357e00c"
integrity sha512-oDM0kUSNFC31ShNxHKUyfZKy8ZeXZBWMjMdZHKLOk13uvT27VTL/QzRGfRUcevJhpkZAvlhPYuXkF7eNWrtyxQ==

indexof@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d"
Expand Down

0 comments on commit 3d2ae6f

Please sign in to comment.