Skip to content

Commit 99c55d3

Browse files
committed
chore(core): remove npmignore post packaging core
We `build plugin` into `dist/libs/core` after `package core` is ran. This is to include a plugin for `angular-three` core to provide generators for `angular-three` and the `plugin` can stay a separate library in the monorepo. However, `ngpackagr` generates a `.npmignore` file to exclude all nested `package.json`. This breaks the `plugin` for Angular CLI because of ESM/CJS problem. The `plugin` comes with its own `package.json` with `type:"commonjs"` so that the generators are interpreted as CJS
1 parent 02bbc13 commit 99c55d3

File tree

4 files changed

+32
-36
lines changed

4 files changed

+32
-36
lines changed

libs/core/project.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"pnpm exec nx build core",
3737
"pnpm exec nx build-ecosystem core",
3838
"pnpm exec nx generate-json core",
39-
"pnpm exec nx build plugin"
39+
"pnpm exec nx build plugin",
40+
"pnpm exec nx post-package core"
4041
],
4142
"parallel": false
4243
}
@@ -60,6 +61,13 @@
6061
"cwd": "dist/libs/core"
6162
}
6263
},
64+
"post-package": {
65+
"executor": "nx:run-commands",
66+
"options": {
67+
"commands": ["node ./tools/scripts/release/post-package-core.mjs"],
68+
"parallel": false
69+
}
70+
},
6371
"test": {
6472
"executor": "@analogjs/vitest-angular:test"
6573
},

libs/plugin/package.json

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
11
{
22
"name": "plugin",
3-
"dependencies": {
4-
"@nx/devkit": "^19.0.0",
5-
"tslib": "^2.3.0"
6-
},
7-
"nx-migrations": {
8-
"migrations": "./migrations.json",
9-
"packageGroup": [
10-
"angular-three-soba",
11-
"angular-three-postprocessing",
12-
"angular-three-cannon",
13-
"angular-three-rapier"
14-
]
15-
},
16-
"ng-update": {
17-
"migrations": "./migrations.json",
18-
"packageGroup": [
19-
"angular-three-soba",
20-
"angular-three-postprocessing",
21-
"angular-three-cannon",
22-
"angular-three-rapier"
23-
]
24-
},
25-
"type": "commonjs",
26-
"generators": "./generators.json"
3+
"type": "commonjs"
274
}

package.json

+9-11
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
"version": "0.0.0",
44
"license": "MIT",
55
"scripts": {
6-
"storybook": "nx storybook soba",
6+
"**comments**": "these scripts are here for convenience to debugging",
77
"generate-json": "node tools/scripts/generate-json.mjs",
88
"generate-soba": "node tools/scripts/generate-soba-json.mjs",
9-
"publish": "nx run-many --target=publish --projects=core,soba,postprocessing,cannon --parallel=false",
10-
"publish:beta": "nx run-many --target=publish --projects=core,soba,postprocessing,cannon --parallel=false --tag=beta",
11-
"commit": "czg"
9+
"commit": "czg"
1210
},
1311
"private": true,
1412
"devDependencies": {
@@ -65,7 +63,7 @@
6563
"autoprefixer": "^10.4.20",
6664
"cypress": "^13.13.2",
6765
"cz-git": "^1.9.4",
68-
"czg": "^1.9.4",
66+
"czg": "^1.9.4",
6967
"dotenv-cli": "^7.4.2",
7068
"enquirer": "^2.4.1",
7169
"eslint": "9.8.0",
@@ -157,11 +155,11 @@
157155
"node_modules/angular-three/web-types.json",
158156
"node_modules/angular-three-soba/web-types.json"
159157
],
160-
"config": {
161-
"commitizen": {
162-
"path": "node_modules/cz-git",
163-
"czConfig": "cz.config.js"
164-
}
165-
},
158+
"config": {
159+
"commitizen": {
160+
"path": "node_modules/cz-git",
161+
"czConfig": "cz.config.js"
162+
}
163+
},
166164
"packageManager": "pnpm@9.6.0"
167165
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* This script is run after `nx package core` is executed
3+
* to remove the `.npmignore` file from the `core` package as we want to publish `plugin` package.json
4+
**/
5+
import { existsSync, unlinkSync } from 'node:fs';
6+
7+
const coreDistPath = './dist/libs/core';
8+
const npmIgnorePath = `${coreDistPath}/.npmignore`;
9+
10+
if (existsSync(npmIgnorePath)) {
11+
console.log('Removing .npmignore from core package');
12+
unlinkSync(npmIgnorePath);
13+
}

0 commit comments

Comments
 (0)