Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(react): rename bundle builder to package #2411

Merged
merged 1 commit into from Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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({});
});
});
@@ -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;
});
}