Skip to content

Commit

Permalink
feat(react): rename bundle builder to package (#2411)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz committed Feb 3, 2020
1 parent 3d36b15 commit ed0f0f8
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 16 deletions.
@@ -1,6 +1,6 @@
# bundle
# package

Bundle a library
Package a library

Builder properties can be configured in angular.json when defining the builder, or when invoking it.

Expand Down
@@ -1,6 +1,6 @@
# bundle
# package

Bundle a library
Package a library

Builder properties can be configured in workspace.json when defining the builder, or when invoking it.
Read more about how to use builders and the CLI here: https://nx.dev/react/guides/cli.
Expand Down
@@ -1,6 +1,6 @@
# bundle
# package

Bundle a library
Package a library

Builder properties can be configured in workspace.json when defining the builder, or when invoking it.
Read more about how to use builders and the CLI here: https://nx.dev/web/guides/cli.
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/schematics/library/library.spec.ts
Expand Up @@ -326,7 +326,7 @@ describe('lib', () => {
const workspaceJson = readJsonInTree(tree, '/workspace.json');

expect(workspaceJson.projects['my-lib'].architect.build).toMatchObject({
builder: '@nrwl/web:bundle',
builder: '@nrwl/web:package',
options: {
entryFile: 'libs/my-lib/src/index.ts',
outputPath: 'dist/libs/my-lib',
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/schematics/library/library.ts
Expand Up @@ -107,7 +107,7 @@ function addProject(options: NormalizedSchema): Rule {

if (options.publishable) {
architect.build = {
builder: '@nrwl/web:bundle',
builder: '@nrwl/web:package',
options: {
outputPath: `dist/libs/${options.projectDirectory}`,
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
Expand Down
8 changes: 4 additions & 4 deletions packages/web/builders.json
Expand Up @@ -6,10 +6,10 @@
"schema": "./src/builders/build/schema.json",
"description": "Build a application"
},
"bundle": {
"implementation": "./src/builders/bundle/bundle.impl",
"schema": "./src/builders/bundle/schema.json",
"description": "Bundle a library"
"package": {
"implementation": "./src/builders/package/package.impl",
"schema": "./src/builders/package/schema.json",
"description": "Package a library"
},
"dev-server": {
"implementation": "./src/builders/dev-server/dev-server.impl",
Expand Down
5 changes: 5 additions & 0 deletions packages/web/migrations.json
Expand Up @@ -4,6 +4,11 @@
"version": "8.5.0-beta.1",
"description": "Update web build builder",
"factory": "./src/migrations/update-8-5-0/update-builder-8-5-0"
},
"update-builder-9.0.0": {
"version": "9.0.0-beta.1",
"description": "Rename @nrwl/web:bundle => @nrwl/web:package",
"factory": "./src/migrations/update-9-0-0/update-builder-9-0-0"
}
}
}
Expand Up @@ -6,14 +6,14 @@ import { workspaces } from '@angular-devkit/core';
import * as f from '@nrwl/workspace/src/utils/fileutils';
import { MockBuilderContext } from '@nrwl/workspace/testing';

import * as impl from './bundle.impl';
import * as impl from './package.impl';
import * as rr from './run-rollup';
import { getMockContext } from '../../utils/testing';
import { BundleBuilderOptions } from '../../utils/types';

jest.mock('tsconfig-paths-webpack-plugin');

describe('WebBuildBuilder', () => {
describe('WebPackagebuilder', () => {
let context: MockBuilderContext;
let testOptions: BundleBuilderOptions;
let runRollup: jasmine.Spy;
Expand Down
@@ -1,6 +1,6 @@
{
"title": "Web Library Bundle Target (Experimental)",
"description": "Bundles a library for web different web usages (UMD, ESM, CJS).",
"title": "Web Library Package Target (Experimental)",
"description": "Pckages a library for web different web usages (UMD, ESM, CJS).",
"type": "object",
"properties": {
"project": {
Expand Down
@@ -0,0 +1,54 @@
import { Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
import {
updateJsonInTree,
readJsonInTree,
updateWorkspaceInTree,
readWorkspace,
getWorkspacePath
} from '@nrwl/workspace';

import * as path from 'path';
import { stripIndents } from '@angular-devkit/core/src/utils/literals';

describe('Update 8-5-0', () => {
let tree: Tree;
let schematicRunner: SchematicTestRunner;

beforeEach(async () => {
tree = Tree.empty();
schematicRunner = new SchematicTestRunner(
'@nrwl/web',
path.join(__dirname, '../../../migrations.json')
);
});

it(`should remove differentialLoading as an option for build builder`, async () => {
tree.create(
'workspace.json',
JSON.stringify({
projects: {
demo: {
root: 'apps/demo',
sourceRoot: 'apps/demo/src',
architect: {
build: {
builder: '@nrwl/web:build',
options: {
differentialLoading: true
}
}
}
}
}
})
);

tree = await schematicRunner
.runSchematicAsync('update-builder-8.5.0', {}, tree)
.toPromise();

const config = readWorkspace(tree);
expect(config.projects.demo.architect.build.options).toEqual({});
});
});
21 changes: 21 additions & 0 deletions packages/web/src/migrations/update-9-0-0/update-builder-9-0-0.ts
@@ -0,0 +1,21 @@
import { Rule } from '@angular-devkit/schematics';
import { updateWorkspaceInTree } from '@nrwl/workspace';

export default function update(): Rule {
return updateWorkspaceInTree(workspaceJson => {
Object.entries<any>(workspaceJson.projects).forEach(
([projectName, project]) => {
Object.entries<any>(project.architect).forEach(
([targetName, targetConfig]) => {
if (targetConfig.builder === '@nrwl/web:bundle') {
workspaceJson.projects[projectName].architect[
targetName
].builder = '@nrwl/web:package';
}
}
);
}
);
return workspaceJson;
});
}

0 comments on commit ed0f0f8

Please sign in to comment.