Skip to content

Commit 173880a

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 4bac418 commit 173880a

File tree

8 files changed

+29
-22
lines changed

8 files changed

+29
-22
lines changed

packages/wasm/.npmignore

Lines changed: 6 additions & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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}/**/*.ts\"",

packages/wasm/rollup.config.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

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

0 commit comments

Comments
 (0)