-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Angular packages with ng-packagr (#2236)
This replaces the use of ngc with ng-packagr when building the angular packages. With this, the libraries don't provide a cjs output anymore, only (partially compiled) *esm. In order to tidy the output, the sources have been moved to a library sub folder and exposed via a commonly used public_api file. The example for the angular material renderer has also been modified to import the output of the library instead of the sources. This allows to actually validate that the package can be loaded and fully compiled (rather than rebuilding everything, the lib + the app, all at once). Therefore, the use of rollup has been dropped in favor of the internal angular browser builder. This also adds `@angular/core` as dev dependency to root package.json to facilitate the new build working with angular-material's `dev` npm script from within the package. --------- Co-authored-by: Lucas Koehler <[email protected]>
- Loading branch information
1 parent
0e4f7ed
commit 3b58277
Showing
81 changed files
with
379 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const path = require('path'); | ||
const ngCore = require('@angular-devkit/core'); | ||
const buildWebpackBrowser = require('@angular-devkit/build-angular/src/builders/browser').buildWebpackBrowser; | ||
|
||
const main = async () => new Promise((resolve, reject) => { | ||
const project = 'angular-material'; | ||
const target = 'build'; | ||
const configuration = ''; | ||
const workspaceRoot = path.join(process.cwd(), '../..'); | ||
const root = `packages/${project}`; | ||
const options = { | ||
outputPath: root + '/example/dist', | ||
tsConfig: root + '/tsconfig.example.json', | ||
main: root + '/example/main.ts', | ||
index: root + '/example/index.html', | ||
styles: [ | ||
root + '/node_modules/@angular/material/prebuilt-themes/indigo-pink.css' | ||
], | ||
allowedCommonJsDependencies: [ | ||
'lodash', | ||
'hammerjs' | ||
], | ||
watch: false, | ||
buildOptimizer: false, | ||
optimization: false, | ||
outputHashing: 'none', | ||
}; | ||
const sourceRoot = root; | ||
const teardownLogics = []; | ||
const context = { | ||
workspaceRoot, | ||
logger: new ngCore.logging.Logger(`${project}:${target}:`), | ||
target: { | ||
project, | ||
configuration, | ||
target | ||
}, | ||
getProjectMetadata: (projectName) => Promise.resolve({ | ||
root, | ||
sourceRoot | ||
}), | ||
getBuilderNameForTarget: () => '@angular-devkit/build-angular:karma', | ||
getTargetOptions: (target) => ({...options}), | ||
validateOptions: (options) => options, | ||
addTeardown: (teardown) => { | ||
teardownLogics.push(teardown); | ||
} | ||
}; | ||
let exitCode = 1; | ||
buildWebpackBrowser(options, context, {}).subscribe({ | ||
next: out => { | ||
if (out.success) { | ||
exitCode = 0; | ||
} | ||
}, | ||
error: (err) => { | ||
reject(err); | ||
}, | ||
complete: () => { | ||
if (!exitCode) return resolve(); | ||
reject(); | ||
} | ||
}); | ||
return exitCode; | ||
}); | ||
|
||
main() | ||
.then(() => { | ||
process.exit(0); | ||
}) | ||
.catch(err => { | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const ngPackage = require('ng-packagr'); | ||
|
||
ngPackage | ||
.ngPackagr() | ||
.forProject('ng-package.json') | ||
.withTsConfig('tsconfig.json') | ||
.build() | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "./node_modules/ng-packagr/ng-package.schema.json", | ||
"dest": "./lib", | ||
"allowedNonPeerDependencies": [ | ||
"@jsonforms/angular", | ||
"@jsonforms/core", | ||
"hammerjs", | ||
"lodash" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.