Skip to content

Tree-Shakeable Tokens #22005

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration/_payload-limits.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"master": {
"uncompressed": {
"inline": 1447,
"main": 154185,
"main": 159944,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change (while awesome!) increased cli hello world by 5.8kb and closure hello world by 4kb. Do we understand why? Is this size increase justified? @alxhub can you please comment?

"polyfills": 59179
}
}
},
"hello_world__closure": {
"master": {
"uncompressed": {
"bundle": 101744
"bundle": 105779
}
}
},
Expand Down
29 changes: 29 additions & 0 deletions integration/injectable-def/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "angular-integration",
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@angular/animations": "file:../../dist/packages-dist/animations",
"@angular/common": "file:../../dist/packages-dist/common",
"@angular/compiler": "file:../../dist/packages-dist/compiler",
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
"@angular/core": "file:../../dist/packages-dist/core",
"@angular/http": "file:../../dist/packages-dist/http",
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
"@angular/platform-server": "file:../../dist/packages-dist/platform-server",
"@types/node": "^9.4.0",
"rxjs": "file:../../node_modules/rxjs",
"typescript": "file:../../node_modules/typescript",
"zone.js": "file:../../node_modules/zone.js"
},
"devDependencies": {
"@types/jasmine": "2.5.41",
"concurrently": "3.4.0",
"lite-server": "2.2.2",
"protractor": "file:../../node_modules/protractor"
},
"scripts": {
"test": "./test.sh"
}
}
21 changes: 21 additions & 0 deletions integration/injectable-def/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServerModule} from '@angular/platform-server';
import {Lib2Module} from 'lib2_built';

@Component({
selector: 'test-app',
template: '<test-cmp></test-cmp>',
})
export class TestApp {}

@NgModule({
declarations: [TestApp],
bootstrap: [TestApp],
imports: [
Lib2Module,
BrowserModule.withServerTransition({appId: 'appId'}),
ServerModule,
],
})
export class AppModule {}
10 changes: 10 additions & 0 deletions integration/injectable-def/src/lib1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Injectable, NgModule} from '@angular/core';

@NgModule({})
export class Lib1Module {}

@Injectable({scope: Lib1Module})
export class Service {
static instance = 0;
readonly instance = Service.instance++;
}
23 changes: 23 additions & 0 deletions integration/injectable-def/src/lib2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {Component, Injector, NgModule} from '@angular/core';
import {Lib1Module, Service} from 'lib1_built';

@Component({
selector: 'test-cmp',
template: '{{instance1}}:{{instance2}}',
})
export class TestCmp {
instance1: number;
instance2: number;

constructor(service: Service, injector: Injector) {
this.instance1 = service.instance;
this.instance2 = injector.get(Service).instance;
}
}

@NgModule({
declarations: [TestCmp],
exports: [TestCmp],
imports: [Lib1Module],
})
export class Lib2Module {}
21 changes: 21 additions & 0 deletions integration/injectable-def/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'zone.js/dist/zone-node';

import {enableProdMode} from '@angular/core';
import {renderModuleFactory} from '@angular/platform-server';
import {AppModuleNgFactory} from './app.ngfactory';

enableProdMode();
renderModuleFactory(AppModuleNgFactory, {
document: '<test-app></test-app>',
url: '/',
}).then(html => {
if (/>0:0</.test(html)) {
process.exit(0);
} else {
console.error('html was', html);
process.exit(1);
}
}).catch(err => {
console.error(err);
process.exit(2);
})
7 changes: 7 additions & 0 deletions integration/injectable-def/src/package-lib1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lib1_built",
"version": "0.0.0",
"license": "MIT",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
7 changes: 7 additions & 0 deletions integration/injectable-def/src/package-lib2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "lib2_built",
"version": "0.0.0",
"license": "MIT",
"main": "./src/index.js",
"typings": "./src/index.d.ts"
}
17 changes: 17 additions & 0 deletions integration/injectable-def/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e -x

NPM_BIN=$(npm bin)
PATH="$PATH:${NPM_BIN}"

rm -rf node_modules/lib1_built node_modules/lib2_built dist/

ngc -p tsconfig-lib1.json
cp src/package-lib1.json node_modules/lib1_built/package.json

ngc -p tsconfig-lib2.json
cp src/package-lib2.json node_modules/lib2_built/package.json

ngc -p tsconfig-app.json

node ./dist/src/main.js
17 changes: 17 additions & 0 deletions integration/injectable-def/tsconfig-app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "dist",
"types": ["node"],
"rootDir": "."
},
"files": [
"src/app.ts",
"src/main.ts"
]
}
22 changes: 22 additions & 0 deletions integration/injectable-def/tsconfig-lib1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"moduleResolution": "node",
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "node_modules/lib1_built",
"types": [],
"rootDir": "."
},
"files": [
"src/lib1.ts"
],
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "lib1_built"
}
}
22 changes: 22 additions & 0 deletions integration/injectable-def/tsconfig-lib2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"moduleResolution": "node",
"lib": ["es2015", "dom"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"outDir": "node_modules/lib2_built",
"types": [],
"rootDir": "."
},
"files": [
"src/lib2.ts"
],
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"flatModuleId": "lib2_built",
"flatModuleOutFile": "index.js"
}
}
1 change: 1 addition & 0 deletions packages/animations/browser/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ ts_library(
module_name = "@angular/animations/browser",
deps = [
"//packages/animations",
"//packages/core",
],
)
2 changes: 2 additions & 0 deletions packages/animations/browser/src/render/animation_driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
* found in the LICENSE file at https://angular.io/license
*/
import {AnimationPlayer, NoopAnimationPlayer} from '@angular/animations';
import {Injectable} from '@angular/core';

import {containsElement, invokeQuery, matchesElement, validateStyleProperty} from './shared';

/**
* @experimental
*/
@Injectable()
export class NoopAnimationDriver implements AnimationDriver {
validateStyleProperty(prop: string): boolean { return validateStyleProperty(prop); }

Expand Down
4 changes: 2 additions & 2 deletions packages/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")

ts_library(
ng_module(
name = "common",
srcs = glob(
[
Expand Down
4 changes: 2 additions & 2 deletions packages/common/http/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ts_library")
load("//tools:defaults.bzl", "ng_module")

ts_library(
ng_module(
name = "http",
srcs = glob(
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")

ng_module(
name = "app",
srcs = glob(
[
"src/**/*.ts",
],
),
module_name = "app_built",
deps = [
"//packages/compiler-cli/integrationtest/bazel/injectable_def/lib2",
"//packages/core",
"//packages/platform-browser",
"//packages/platform-server",
"@rxjs",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Component, NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServerModule} from '@angular/platform-server';
import {Lib2Module} from 'lib2_built/module';

@Component({
selector: 'id-app',
template: '<lib2-cmp></lib2-cmp>',
})
export class AppComponent {
}

@NgModule({
imports: [
Lib2Module,
BrowserModule.withServerTransition({appId: 'id-app'}),
ServerModule,
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class BasicAppModule {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {Component, Injectable, NgModule, Optional, Self} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {ServerModule} from '@angular/platform-server';

@Injectable()
export class Service {
}

@Component({
selector: 'hierarchy-app',
template: '<child-cmp></child-cmp>',
providers: [Service],
})
export class AppComponent {
}

@Component({
selector: 'child-cmp',
template: '{{found}}',
})
export class ChildComponent {
found: boolean;

constructor(@Optional() @Self() service: Service|null) { this.found = !!service; }
}

@NgModule({
imports: [
BrowserModule.withServerTransition({appId: 'hierarchy-app'}),
ServerModule,
],
declarations: [AppComponent, ChildComponent],
bootstrap: [AppComponent],
})
export class HierarchyAppModule {
}
Loading