Skip to content

Commit 20b4bb9

Browse files
committed
add central build dir to @sentry/wasm
adjust postbuild.ts to take optional CL arg to not tmp copy CDN bundles
1 parent 7b49f65 commit 20b4bb9

File tree

8 files changed

+29
-22
lines changed

8 files changed

+29
-22
lines changed

packages/wasm/.npmignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
# Info: the paths in this file are specified so that they align with the file
2+
# structure in `./build` where this file is copied to. This is done by the
3+
# postbuild script `sentry-javascript/scripts/postbuild.ts`.
4+
15
*
6+
27
!/dist/**/*
38
!/esm/**/*
4-
!/build/types/**/*
9+
!/types/**/*

packages/wasm/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"engines": {
1010
"node": ">=6"
1111
},
12-
"main": "dist/index.js",
13-
"module": "esm/index.js",
14-
"types": "build/types/index.d.ts",
12+
"main": "build/npm/dist/index.js",
13+
"module": "build/npm/esm/index.js",
14+
"types": "build/npm/types/index.d.ts",
1515
"publishConfig": {
1616
"access": "public"
1717
},
@@ -29,7 +29,7 @@
2929
"puppeteer": "^5.5.0"
3030
},
3131
"scripts": {
32-
"build": "run-p build:cjs build:esm build:bundle build:types",
32+
"build": "run-p build:cjs build:esm build:bundle build:types && ts-node ../../scripts/postbuild.ts -skipBundleCopy",
3333
"build:bundle": "rollup --config",
3434
"build:cjs": "tsc -p tsconfig.cjs.json",
3535
"build:dev": "run-p build:cjs build:esm build:types",
@@ -43,9 +43,9 @@
4343
"build:es5:watch": "yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***",
4444
"build:esm:watch": "tsc -p tsconfig.esm.json --watch",
4545
"build:types:watch": "tsc -p tsconfig.types.json --watch",
46-
"build:npm": "npm pack",
46+
"build:npm": "npm pack ./build/npm",
4747
"circularDepCheck": "madge --circular src/index.ts",
48-
"clean": "rimraf dist esm coverage *.js.map *.d.ts",
48+
"clean": "rimraf dist esm build coverage *.js.map *.d.ts",
4949
"fix": "run-s fix:eslint fix:prettier",
5050
"fix:eslint": "eslint . --format stylish --fix",
5151
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",

packages/wasm/rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const baseBundleConfig = makeBaseBundleConfig({
55
isAddOn: true,
66
jsVersion: 'es5',
77
licenseTitle: '@sentry/wasm',
8-
outputFileBase: 'wasm',
8+
outputFileBase: 'bundles/wasm',
99
});
1010

1111
export default makeConfigVariants(baseBundleConfig);

packages/wasm/test/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const app = express();
66
// Wasm Integration Tests Artifacts
77
app.use(express.static(path.resolve(__dirname, 'public')));
88
// Wasm Integration Bundle
9-
app.use(express.static(path.resolve(__dirname, '../build')));
9+
app.use(express.static(path.resolve(__dirname, '../build/bundles')));
1010
// Browser SDK Bundle
1111
app.use(express.static(path.resolve(__dirname, '../../browser/build/bundles')));
1212
app.listen(process.env.PORT);

packages/wasm/tsconfig.cjs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
"compilerOptions": {
55
"module": "commonjs",
6-
"outDir": "dist"
6+
"outDir": "build/npm/dist"
77
}
88
}

packages/wasm/tsconfig.esm.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
"compilerOptions": {
55
"module": "es6",
6-
"outDir": "esm"
6+
"outDir": "build/npm/esm"
77
}
88
}

packages/wasm/tsconfig.types.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"declaration": true,
66
"declarationMap": true,
77
"emitDeclarationOnly": true,
8-
"outDir": "build/types"
8+
"outDir": "build/npm/types"
99
}
1010
}

scripts/postbuild.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ ASSETS.forEach(asset => {
4343
// TODO remove in v7! Until then:
4444
// copy CDN bundles into npm dir to temporarily keep bundles in npm tarball
4545
// inside the tarball, they are located in `build/`
46-
const npmTmpBundlesPath = path.resolve(NPM_BUILD_DIR, 'build');
47-
const cdnBundlesPaht = path.resolve('build', 'bundles');
48-
try {
49-
if (!fs.existsSync(npmTmpBundlesPath)) {
50-
fs.mkdirSync(npmTmpBundlesPath);
46+
// for now, copy it by default, unless explicitly forbidden via an command line arg
47+
const tmpCopyBundles = !process.argv.includes('-skipBundleCopy');
48+
if (tmpCopyBundles) {
49+
const npmTmpBundlesPath = path.resolve(NPM_BUILD_DIR, 'build');
50+
const cdnBundlesPaht = path.resolve('build', 'bundles');
51+
try {
52+
if (!fs.existsSync(npmTmpBundlesPath)) {
53+
fs.mkdirSync(npmTmpBundlesPath);
54+
}
55+
fse.copy(cdnBundlesPaht, npmTmpBundlesPath);
56+
} catch (error) {
57+
console.error(`Error while tmp copying CDN bundles to ${NPM_BUILD_DIR}`);
5158
}
52-
fse.copy(cdnBundlesPaht, npmTmpBundlesPath);
53-
} catch (error) {
54-
console.error(`Error while tmp copying CDN bundles to ${NPM_BUILD_DIR}`);
5559
}
56-
// end remove
57-
5860
// package.json modifications
5961
const packageJsonPath = path.resolve(NPM_BUILD_DIR, 'package.json');
6062
const pkgJson: { [key: string]: unknown } = require(packageJsonPath);

0 commit comments

Comments
 (0)