Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: publish should build without cache #701

Merged
merged 3 commits into from Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
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
24 changes: 16 additions & 8 deletions scripts/build.js
@@ -1,14 +1,19 @@
const ncc = require("../src/index.js");
const { statSync, writeFileSync, readFileSync, unlinkSync } = require("fs");
const { statSync, writeFileSync, readFileSync, unlinkSync, rmdirSync } = 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 = join(__dirname, "..", ".cache");
guybedford marked this conversation as resolved.
Show resolved Hide resolved

async function main() {
if (process.argv[2] === "--no-cache") {
rmdirSync(cache, { recursive: true });
}
guybedford marked this conversation as resolved.
Show resolved Hide resolved
for (const file of await glob(__dirname + "/../dist/**/*.@(js|cache|ts)")) {
unlinkSync(file);
}
Expand All @@ -20,7 +25,8 @@ async function main() {
externals: ["./index.js"],
license: 'LICENSES.txt',
minify,
v8cache: true
cache,
v8cache
}
);
checkUnknownAssets('cli', Object.keys(cliAssets));
Expand All @@ -30,7 +36,8 @@ async function main() {
{
filename: "index.js",
minify,
v8cache: true
cache,
v8cache
}
);
checkUnknownAssets('index', Object.keys(indexAssets).filter(asset =>
Expand All @@ -39,13 +46,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 +61,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
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