Skip to content

Commit

Permalink
fix(angular): fixes sourcemap generation for the code built by ngc
Browse files Browse the repository at this point in the history
Fixes #387, #382
  • Loading branch information
stalniy committed Sep 3, 2020
1 parent b2ad140 commit 7715263
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 26 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"husky": "^4.0.0",
"lint-staged": "^10.0.10",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"typescript": "~3.8.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/casl-ability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"eslint-plugin-import": "^2.20.2",
"jest": "^26.0.0",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"semantic-release": "17.1.1",
"typescript": "~3.8.0"
Expand Down
5 changes: 0 additions & 5 deletions packages/casl-angular/.eslintrc

This file was deleted.

5 changes: 3 additions & 2 deletions packages/casl-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "dist/umd/index.js",
"module": "dist/es5m/index.js",
"es2015": "dist/es6/index.js",
"typings": "dist/types/public_api.d.ts",
"typings": "dist/types/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/stalniy/casl.git"
Expand All @@ -20,7 +20,7 @@
"build.es6": "TARGET=es2015 BUILD=es6 npm run rollup",
"build.umd": "TARGET=es5 BUILD=umd npm run rollup",
"build.types": "ngc -p tsconfig.types.json",
"rollup": "ngc --target $TARGET --outDir dist/$BUILD/tmp && LIB_MINIFY=false BUILD_TYPES=$BUILD USE_SRC_MAPS=1 rollup -c ../../rollup.config.js -i dist/$BUILD/tmp/index.js -n casl.ng -g @angular/core:ng.core,@casl/ability:casl,tslib:tslib,rxjs:rxjs",
"rollup": "ngc -p tsconfig.lib.json --target $TARGET --outDir dist/$BUILD/tmp && LIB_MINIFY=false BUILD_TYPES=$BUILD ES_TRANSFORM=false rollup -c ../../rollup.config.js -i dist/$BUILD/tmp/index.js -n casl.ng -g @angular/core:ng.core,@casl/ability:casl,tslib:tslib,rxjs:rxjs",
"postrollup": "rm -rf dist/$BUILD/tmp",
"test": "NODE_ENV=test jest --config ./jest.config.js",
"lint": "eslint --ext .ts,.js src/ spec/",
Expand Down Expand Up @@ -79,6 +79,7 @@
"jest": "^26.0.0",
"jest-zone-patch": "0.0.10",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"rxjs": "^6.0.0",
"semantic-release": "17.1.1",
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions packages/casl-angular/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compileOnSave": false,
"compilerOptions": {
"inlineSources": true,
"inlineSourceMap": true,
"declaration": false,
"module": "es2015",
Expand All @@ -16,15 +17,16 @@
"dom"
]
},
"files": [
"src/index.ts"
"include": [
"src/*",
"spec/*"
],
"angularCompilerOptions": {
"enableIvy": false,
"skipMetadataEmit": true,
"skipTemplateCodegen": true,
"strictInjectionParameters": true,
"flatModuleOutFile": "public_api.js",
"flatModuleOutFile": "index.js",
"flatModuleId": "@casl/angular"
}
}
}
6 changes: 6 additions & 0 deletions packages/casl-angular/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"include": [
"src/public.ts"
]
}
8 changes: 2 additions & 6 deletions packages/casl-angular/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"extends": "./tsconfig.json",
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"declaration": true,
"outDir": "dist/types"
},
"angularCompilerOptions": {
"skipMetadataEmit": false
},
"include": [
"src/*",
"spec/*"
]
}
}
1 change: 1 addition & 0 deletions packages/casl-aurelia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"eslint-plugin-import": "^2.20.2",
"jest": "^26.0.0",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"semantic-release": "17.1.1",
"typescript": "~3.8.0"
Expand Down
1 change: 1 addition & 0 deletions packages/casl-mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"jest": "^26.0.0",
"mongoose": "^5.0.14",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"semantic-release": "17.1.1",
"typescript": "~3.8.0"
Expand Down
1 change: 1 addition & 0 deletions packages/casl-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"react": "^16.3.0",
"react-test-renderer": "^16.3.0",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"semantic-release": "17.1.1",
"typescript": "~3.8.0"
Expand Down
1 change: 1 addition & 0 deletions packages/casl-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"eslint-plugin-import": "^2.20.2",
"jest": "^26.0.0",
"rollup": "^2.10.9",
"rollup-plugin-sourcemaps": "^0.6.2",
"rollup-plugin-terser": "^7.0.0",
"semantic-release": "17.1.1",
"typescript": "~3.8.0",
Expand Down
48 changes: 48 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import sourcemaps from 'rollup-plugin-sourcemaps';

function aggregate(configs, optionsOverrides) {
let external = [];
Expand Down Expand Up @@ -58,15 +59,16 @@ function aggregate(configs, optionsOverrides) {
mainFields: ['module', 'main', 'browser'],
extensions: ['.js', '.mjs', '.ts'],
}),
babel({
rootMode: 'upward',
extensions: ['.js', '.mjs', '.ts'],
inputSourceMap: !!process.env.USE_SRC_MAPS,
babelHelpers: 'bundled',
caller: {
output: config.type,
}
}),
process.env.ES_TRANSFORM === 'false'
? sourcemaps()
: babel({
rootMode: 'upward',
extensions: ['.js', '.mjs', '.ts'],
babelHelpers: 'bundled',
caller: {
output: config.type,
}
}),
...(config.plugins || [])
]
}));
Expand Down

0 comments on commit 7715263

Please sign in to comment.