Skip to content

Commit

Permalink
update for Angular 12
Browse files Browse the repository at this point in the history
  • Loading branch information
manfredsteyer committed May 1, 2021
1 parent c6ba40a commit 8a4ffac
Show file tree
Hide file tree
Showing 9 changed files with 924 additions and 302 deletions.
1,180 changes: 898 additions & 282 deletions lib/package-lock.json

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-build-plus",
"version": "11.0.0",
"version": "12.0.0-beta.1",
"description": "Extends the Angular CLI's build process!",
"license": "MIT",
"repository": {
Expand All @@ -21,14 +21,11 @@
"build": "npm run tsc && npm run copy:sample && npm run copy:readme"
},
"dependencies": {
"@schematics/angular": "8.0.0",
"cross-spawn": "^6.0.5",
"rxjs": "6.4.0",
"webpack-dev-server": "^3.1.14",
"webpack-merge": "^4.2.1"
"@schematics/angular": "^12.0.0-rc.0",
"webpack-merge": "^5.0.0"
},
"peerDependencies": {
"@angular-devkit/build-angular": ">=0.900.0",
"@angular-devkit/build-angular": ">=12.0.0-rc.0",
"rxjs": ">= 6.0.0"
},
"devDependencies": {
Expand All @@ -40,6 +37,7 @@
"@types/webpack": "^4.4.22",
"@types/webpack-dev-server": "^3.1.1",
"cpr": "^3.0.1",
"rxjs": "^7.0.0",
"typescript": "^3.4.5",
"webpack": "^4.28.4",
"webpack-merge": "^4.2.1"
Expand Down
4 changes: 2 additions & 2 deletions lib/schematics/add-ngx-build-plus/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/config';
import { getWorkspace, updateWorkspace } from '../utils/workspace';

export function addNgxBuildPlus(_options: any): Rule {
return (tree: Tree, _context: SchematicContext) => {
Expand All @@ -24,7 +24,7 @@ export function addNgxBuildPlus(_options: any): Rule {
const test = architect.test;
if (test) test.builder = <any>'ngx-build-plus:karma';

return updateWorkspace(workspace);
return updateWorkspace(tree, workspace);
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/schematics/add-ngx-build-plus/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema",
"id": "SchemanticsForMenu",
"$id": "AddNgxBuildPlus",
"title": "Menu Schema",
"type": "object",
"properties": {
Expand Down
7 changes: 3 additions & 4 deletions lib/schematics/externals/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Rule, SchematicContext, Tree, apply, url, template, move, branchAndMerge, mergeWith, chain, noop } from '@angular-devkit/schematics';
import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/config';
import { getWorkspace, updateWorkspace } from '../utils/workspace';
import * as path from 'path';
import { BrowserBuilderBaseOptions } from '@schematics/angular/utility/workspace-models';
import { AdvancedScriptConf } from '../utils/types';
import { spawn } from 'cross-spawn';
import { RunSchematicTask } from '@angular-devkit/schematics/tasks';


Expand Down Expand Up @@ -73,8 +71,9 @@ function addScriptsToProject(tree: Tree, options: any): Rule {
scripts.push(script);
});

return updateWorkspace(workspace);
updateWorkspace(tree, workspace);

return noop();
}

function getProject(tree: Tree, options: any) {
Expand Down
2 changes: 1 addition & 1 deletion lib/schematics/externals/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/schema",
"id": "SchemanticsForMenu",
"$id": "Externals",
"title": "Menu Schema",
"type": "object",
"properties": {
Expand Down
9 changes: 9 additions & 0 deletions lib/schematics/utils/workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Tree } from "@angular-devkit/schematics";

export function getWorkspace(tree: Tree) {
return JSON.parse(tree.read('angular.json')!.toString('utf-8'));
}

export function updateWorkspace(tree: Tree, workspace: any) {
tree.overwrite('angular.json', JSON.stringify(workspace));
}
6 changes: 3 additions & 3 deletions lib/schematics/webcomponents-polyfill/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rule, SchematicContext, Tree, apply, url, template, move, branchAndMerge, mergeWith, chain, noop } from '@angular-devkit/schematics';
import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/config';
import { getWorkspace, updateWorkspace } from '../utils/workspace';
import { RunSchematicTask, NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import { BrowserBuilderBaseOptions } from '@schematics/angular/utility/workspace-models';
import { AdvancedScriptConf } from '../utils/types';
Expand Down Expand Up @@ -72,8 +72,8 @@ function addScriptsToProject(tree: Tree, options: any): Rule {
});
}

return updateWorkspace(workspace);

updateWorkspace(tree, workspace);
return noop();
}

function loadPackageJson(tree: Tree) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { loadHook } from "../ext/load-hook";
import { getSystemPath, normalize } from '@angular-devkit/core';
import * as webpack from 'webpack';
import * as path from 'path';
import * as webpackMerge from 'webpack-merge';
import { merge as webpackMerge } from 'webpack-merge';

export interface Transforms {
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;
Expand Down Expand Up @@ -71,7 +71,7 @@ function setupConfigHook(transforms: Transforms, options: any, context: BuilderC

const keepStyles = !options.bundleStyles || options.keepStyles;

if (options.singleBundle && !keepStyles && config.entry && config.entry['styles']) {
if (options.singleBundle && ! keepStyles && config.entry && config.entry['styles']) {
delete config.entry['styles'];
}

Expand Down

0 comments on commit 8a4ffac

Please sign in to comment.