Skip to content

Commit 4726a05

Browse files
committed
build: switching to webpack instead of ncc
1 parent b7ea9c0 commit 4726a05

File tree

5 files changed

+150
-30
lines changed

5 files changed

+150
-30
lines changed

libs/ng-mocks/tsconfig.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,15 @@
66
"moduleResolution": "node",
77
"esModuleInterop": true,
88
"forceConsistentCasingInFileNames": true,
9-
"emitDecoratorMetadata": true,
109
"downlevelIteration": true,
1110
"declaration": true,
1211
"importHelpers": false,
1312
"outDir": "../../dist/libs/ng-mocks",
1413
"declarationDir": "../../dist/libs/ng-mocks",
1514
"allowSyntheticDefaultImports": true,
1615
"removeComments": false,
17-
"experimentalDecorators": true,
18-
"types": [
19-
"jasmine",
20-
"jest",
21-
"karma-coverage-istanbul-reporter",
22-
"karma-jasmine",
23-
"karma-junit-reporter",
24-
"karma-webpack",
25-
"mocha",
26-
"node"
27-
],
2816
"baseUrl": ".",
29-
"paths": {
30-
"ng-mocks": ["./src/index.ts"]
31-
},
17+
"sourceMap": true,
3218
"skipLibCheck": true,
3319

3420
"noFallthroughCasesInSwitch": true,

package-lock.json

Lines changed: 95 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
"npm": "npm",
66
"postinstall": "husky install",
77
"release": "export $(cat .env) && semantic-release",
8-
"build": "npm run clean && npm run build:ncc && npm run build:fix && cp CHANGELOG.md dist/libs/ng-mocks && cp README.md dist/libs/ng-mocks && cp LICENSE dist/libs/ng-mocks && cp libs/ng-mocks/package.json dist/libs/ng-mocks/package.json && cp libs/ng-mocks/migrations.json dist/libs/ng-mocks/migrations.json && cp -R examples dist/libs/ng-mocks",
9-
"build:ncc": "cd ./libs/ng-mocks && npx ncc build --no-source-map-register -m -e '@angular/animations' -e '@angular/cli' -e '@angular/common' -e '@angular/common/http' -e '@angular/core' -e '@angular/core/testing' -e '@angular/forms' -e '@angular/platform-browser' -e '@angular/platform-browser/animations' -e '@angular/platform-browser-dynamic' -e '@angular/router' ./src/index.ts -o ../../dist/libs/ng-mocks/",
10-
"build:fix": "sed -e 's/__dirname/(typeof __dirname===\"undefined\"?\"\":__dirname)/g' dist/libs/ng-mocks/index.js > dist/libs/ng-mocks/index.fix.js && mv dist/libs/ng-mocks/index.fix.js dist/libs/ng-mocks/index.js",
11-
"build:sources": "cp -R libs/ng-mocks/src dist/libs/ng-mocks && sed -e 's/\\.\\.\\/webpack:\\/\\/ng-mocks\\///g' dist/libs/ng-mocks/index.js.map > dist/libs/ng-mocks/index.fix.js.map && mv dist/libs/ng-mocks/index.fix.js.map dist/libs/ng-mocks/index.js.map",
8+
"build": "npm run clean && npm run build:webpack && npm run build:types && cp CHANGELOG.md dist/libs/ng-mocks && cp README.md dist/libs/ng-mocks && cp LICENSE dist/libs/ng-mocks && cp libs/ng-mocks/package.json dist/libs/ng-mocks/package.json && cp libs/ng-mocks/migrations.json dist/libs/ng-mocks/migrations.json && cp -R examples dist/libs/ng-mocks",
9+
"build:webpack": "webpack",
10+
"build:types": "tsc -p ./libs/ng-mocks/tsconfig.json --emitDeclarationOnly",
1211
"build:all": "npm run lint && npm run build && npm run test",
1312
"build:docs": "cd docs && CI=true npm run build",
1413
"clean": "rm -rf dist test-reports tmp",
@@ -186,7 +185,6 @@
186185
"@types/karma-webpack": "2.0.11",
187186
"@types/mocha": "9.1.0",
188187
"@types/node": "14.18.10",
189-
"@vercel/ncc": "0.33.1",
190188
"codecov": "3.8.3",
191189
"core-js": "3.21.0",
192190
"coverage-istanbul-loader": "3.0.5",
@@ -219,6 +217,7 @@
219217
"tslint-microsoft-contrib": "6.2.0",
220218
"typescript": "4.5.5",
221219
"webpack": "5.68.0",
220+
"webpack-cli": "4.9.2",
222221
"zone.js": "0.11.4"
223222
},
224223
"repository": {

tsconfig.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
{
22
"extends": "./libs/ng-mocks/tsconfig.json",
33
"compilerOptions": {
4-
"inlineSourceMap": false,
5-
"inlineSources": true,
6-
"sourceMap": true,
4+
"emitDecoratorMetadata": true,
5+
"experimentalDecorators": true,
76
"noUnusedLocals": false,
8-
"noUnusedParameters": false
7+
"noUnusedParameters": false,
8+
"paths": {
9+
"ng-mocks": ["./src/index.ts"]
10+
},
11+
"types": [
12+
"jasmine",
13+
"jest",
14+
"karma-coverage-istanbul-reporter",
15+
"karma-jasmine",
16+
"karma-junit-reporter",
17+
"karma-webpack",
18+
"mocha",
19+
"node"
20+
]
921
},
1022
"files": ["libs/ng-mocks/src/index.ts", "empty.ts", "karma-test-shim.ts", "karma.conf.ts"],
1123
"exclude": ["e2e", "node_modules"],

webpack.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
mode: 'production',
5+
devtool: 'source-map',
6+
entry: './libs/ng-mocks/src/index.ts',
7+
output: {
8+
path: path.resolve(__dirname, './dist/libs/ng-mocks/'),
9+
filename: 'index.js',
10+
library: {
11+
type: 'umd',
12+
},
13+
},
14+
externals: /^@angular\//,
15+
module: {
16+
rules: [
17+
{
18+
test: /\.tsx?$/,
19+
use: [
20+
{
21+
loader: 'ts-loader',
22+
options: {
23+
configFile: path.resolve(__dirname, './libs/ng-mocks/tsconfig.json'),
24+
transpileOnly: true,
25+
},
26+
},
27+
],
28+
},
29+
],
30+
},
31+
resolve: {
32+
extensions: ['.js', '.cjs', '.mjs', '.ts', '.json'],
33+
},
34+
};

0 commit comments

Comments
 (0)