diff --git a/package.json b/package.json index 38dd444f..3f4168a5 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/scripts/build.js b/scripts/build.js index 06850388..2347c0a7 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -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)")) { @@ -20,7 +22,8 @@ async function main() { externals: ["./index.js"], license: 'LICENSES.txt', minify, - v8cache: true + cache, + v8cache } ); checkUnknownAssets('cli', Object.keys(cliAssets)); @@ -30,7 +33,8 @@ async function main() { { filename: "index.js", minify, - v8cache: true + cache, + v8cache } ); checkUnknownAssets('index', Object.keys(indexAssets).filter(asset => @@ -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)); @@ -54,7 +58,8 @@ async function main() { { filename: "ts-loader.js", minify, - v8cache: true, + cache, + v8cache, noAssetBuilds: true }, ); @@ -62,7 +67,7 @@ async function main() { 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)); diff --git a/yarn.lock b/yarn.lock index 18190e30..866d56e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"