Skip to content

Commit ce1baff

Browse files
CaerusKaruvikerman
authored andcommitted
build(lib): fix secondary entrypoints and bundle with APF v5 (#940)
* Revert back to APF bundling to resolve build issues * Incorporate Material build system to handle secondary entrypoints and bundling
1 parent 24adea6 commit ce1baff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1271
-322
lines changed

build-config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const buildLicense = `/**
2525
*/`;
2626

2727
/** The namespace for the packages. Instead of @angular, we use @nguniversal */
28-
const namespace = '@nguniversal';
28+
const namespace = 'nguniversal';
2929

3030
/** The library entrypoints that are built under the namespace */
3131
const libNames = [
@@ -40,7 +40,7 @@ module.exports = {
4040
projectVersion: buildVersion,
4141
angularVersion: angularVersion,
4242
projectDir: __dirname,
43-
packagesDir: join(__dirname, 'src'),
43+
packagesDir: join(__dirname, 'modules'),
4444
outputDir: join(__dirname, 'dist'),
4545
licenseBanner: buildLicense,
4646
namespace,

build-test.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import {buildConfig, buildLib} from './tools/package-tools';
1+
import {buildConfig, BuildPackage, packages} from './tools/package-tools';
22

33
declare var require: any;
44

55
const rimraf = require('rimraf');
66

7+
const buildPkg = async (pkg: BuildPackage) => {
8+
pkg.dependencies.forEach(buildPkg);
9+
await pkg.compileTests();
10+
};
11+
12+
713
rimraf(buildConfig.outputDir, async () => {
8-
for (const lib of buildConfig.libNames) {
9-
const exitCode = await buildLib(lib, true);
10-
console.log(exitCode === 0 ? `Build succeeded for ${lib}` : `Build failed for ${lib}`);
11-
console.log();
14+
for (const pkg of packages) {
15+
console.log(`Building package to test: ${pkg.name}`);
16+
await buildPkg(pkg);
17+
console.log(`Finished building: ${pkg.name}`);
1218
}
1319
});

build.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
import {buildConfig, buildLib} from './tools/package-tools';
1+
import {buildConfig, BuildPackage, composeRelease, packages} from './tools/package-tools';
22

33
declare var require: any;
44

55
const rimraf = require('rimraf');
66

7+
const buildPkg = async (pkg: BuildPackage) => {
8+
pkg.dependencies.forEach(buildPkg);
9+
await pkg.compile();
10+
await pkg.createBundles();
11+
};
12+
13+
714
rimraf(buildConfig.outputDir, async () => {
8-
for (const lib of buildConfig.libNames) {
9-
const exitCode = await buildLib(lib);
10-
console.log(exitCode === 0 ? `Build succeeded for ${lib}` : `Build failed for ${lib}`);
11-
console.log();
15+
for (const pkg of packages) {
16+
console.log(`Building package: ${pkg.name}`);
17+
await buildPkg(pkg);
18+
composeRelease(pkg);
19+
console.log(`Finished building: ${pkg.name}`);
1220
}
1321
});

modules/aspnetcore-engine/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nguniversal/aspnetcore-engine",
3-
"version": "5.0.0-beta.6",
3+
"version": "0.0.0-PLACEHOLDER",
44
"description": "ASP.NET Core Engine for running Server Angular Apps",
55
"main": "./bundles/aspnetcore-engine.umd.js",
66
"module": "./esm5/aspnetcore-engine.es5.js",
@@ -21,8 +21,8 @@
2121
"universal"
2222
],
2323
"peerDependencies": {
24-
"@angular/common": "^5.0.0",
25-
"@angular/core": "^5.0.0"
24+
"@angular/common": "0.0.0-NG",
25+
"@angular/core": "0.0.0-NG"
2626
},
2727
"repository": {
2828
"type": "git",

modules/aspnetcore-engine/src/main.ts

+21-12
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { Type, NgModuleFactory, CompilerFactory, Compiler } from '@angular/core';
8+
import {Type, NgModuleFactory, CompilerFactory, Compiler, StaticProvider} from '@angular/core';
99
import { platformDynamicServer } from '@angular/platform-server';
1010
import { DOCUMENT } from '@angular/common';
1111
import { ResourceLoader } from '@angular/compiler';
1212

13-
import { REQUEST, ORIGIN_URL } from '../tokens';
13+
import { REQUEST, ORIGIN_URL } from '@nguniversal/aspnetcore-engine/tokens';
1414
import { FileLoader } from './file-loader';
1515
import { IEngineOptions } from './interfaces/engine-options';
1616
import { IEngineRenderResult } from './interfaces/engine-render-result';
@@ -121,16 +121,8 @@ export function ngAspnetCoreEngine(options: IEngineOptions): Promise<IEngineRend
121121

122122
options.providers = options.providers || [];
123123

124-
const extraProviders = options.providers.concat(
125-
[{
126-
provide: ORIGIN_URL,
127-
useValue: options.request.origin
128-
}, {
129-
provide: REQUEST,
130-
useValue: options.request.data.request
131-
}
132-
]
133-
);
124+
const extraProviders = options.providers.concat(getReqResProviders(options.request.origin,
125+
options.request.data.request));
134126

135127
getFactory(moduleOrFactory, compiler)
136128
.then(factory => {
@@ -167,6 +159,23 @@ export function ngAspnetCoreEngine(options: IEngineOptions): Promise<IEngineRend
167159

168160
}
169161

162+
/**
163+
* Get providers of the request and response
164+
*/
165+
function getReqResProviders(origin: string, request: string): StaticProvider[] {
166+
const providers: StaticProvider[] = [
167+
{
168+
provide: ORIGIN_URL,
169+
useValue: origin
170+
},
171+
{
172+
provide: REQUEST,
173+
useValue: request
174+
}
175+
];
176+
return providers;
177+
}
178+
170179
/* @internal */
171180
const factoryCacheMap = new Map<Type<{}>, NgModuleFactory<{}>>();
172181
function getFactory(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
export * from './public-api';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
export * from './tokens';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.lib",
3+
"files": [
4+
"public-api.ts"
5+
],
6+
"angularCompilerOptions": {
7+
"annotateForClosureCompiler": true,
8+
"strictMetadataEmit": false, // Workaround for Angular #22210
9+
"flatModuleOutFile": "index.js",
10+
"flatModuleId": "@nguniversal/aspnetcore-engine/tokens",
11+
"skipTemplateCodegen": true,
12+
"fullTemplateTypeCheck": true
13+
}
14+
}

modules/aspnetcore-engine/tsconfig.fortokens.json

-7
This file was deleted.

modules/aspnetcore-engine/tsconfig.lib.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@
2121
"lib": ["es2015", "dom"],
2222
"skipLibCheck": true,
2323
"types": ["node"],
24-
"baseUrl": "."
24+
"baseUrl": ".",
25+
"paths": {
26+
"@nguniversal/aspnetcore-engine/*": ["../../dist/packages/aspnetcore-engine/*"]
27+
}
2528
},
2629
"files": [
27-
"./public-api.ts"
30+
"public-api.ts"
2831
],
2932
"angularCompilerOptions": {
3033
"annotateForClosureCompiler": true,
31-
"strictMetadataEmit": true,
32-
"skipTemplateCodegen": true,
34+
"strictMetadataEmit": false, // Workaround for Angular #22210
3335
"flatModuleOutFile": "index.js",
34-
"flatModuleId": "@nguniversal/aspnetcore-engine"
36+
"flatModuleId": "@nguniversal/aspnetcore-engine",
37+
"skipTemplateCodegen": true,
38+
"fullTemplateTypeCheck": true
3539
}
3640
}

modules/aspnetcore-engine/tsconfig.spec.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"types": ["jasmine", "node"]
1111
},
1212
"angularCompilerOptions": {
13-
"strictMetadataEmit": true,
13+
"strictMetadataEmit": false, // Workaround for Angular #22210
1414
"skipTemplateCodegen": true,
1515
"emitDecoratorMetadata": true,
1616
"fullTemplateTypeCheck": true

modules/common/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nguniversal/common",
3-
"version": "5.0.0-beta.6",
3+
"version": "0.0.0-PLACEHOLDER",
44
"description": "Angular Universal common utilities",
55
"main": "./bundles/common.umd.js",
66
"module": "./esm5/common.es5.js",
@@ -12,8 +12,8 @@
1212
"universal"
1313
],
1414
"peerDependencies": {
15-
"@angular/common": "^5.0.0",
16-
"@angular/core": "^5.0.0"
15+
"@angular/common": "0.0.0-NG",
16+
"@angular/core": "0.0.0-NG"
1717
},
1818
"repository": {
1919
"type": "git",

modules/common/tsconfig.lib.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@
2121
"lib": ["es2015", "dom"],
2222
"skipLibCheck": true,
2323
"types": [],
24-
"baseUrl": "."
24+
"baseUrl": ".",
25+
"paths": {
26+
"@nguniversal/common/*": ["../../dist/packages/common/*"]
27+
}
2528
},
2629
"files": [
27-
"./public-api.ts"
30+
"public-api.ts"
2831
],
2932
"angularCompilerOptions": {
3033
"annotateForClosureCompiler": true,
31-
"strictMetadataEmit": true,
32-
"skipTemplateCodegen": true,
34+
"strictMetadataEmit": false, // Workaround for Angular #22210
3335
"flatModuleOutFile": "index.js",
34-
"flatModuleId": "@nguniversal/common"
36+
"flatModuleId": "@nguniversal/common",
37+
"skipTemplateCodegen": true,
38+
"fullTemplateTypeCheck": true
3539
}
3640
}

modules/common/tsconfig.spec.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"types": ["jasmine"]
1111
},
1212
"angularCompilerOptions": {
13-
"strictMetadataEmit": true,
13+
"strictMetadataEmit": false, // Workaround for Angular #22210
1414
"skipTemplateCodegen": true,
1515
"emitDecoratorMetadata": true,
1616
"fullTemplateTypeCheck": true

modules/express-engine/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nguniversal/express-engine",
3-
"version": "5.0.0-beta.6",
3+
"version": "0.0.0-PLACEHOLDER",
44
"description": "Express Engine for running Server Angular Apps",
55
"main": "./bundles/express-engine.umd.js",
66
"module": "./esm5/express-engine.es5.js",
@@ -13,9 +13,9 @@
1313
"universal"
1414
],
1515
"peerDependencies": {
16-
"@angular/common": "^5.0.0",
17-
"@angular/core": "^5.0.0",
18-
"@angular/platform-server": "^5.0.0",
16+
"@angular/common": "0.0.0-NG",
17+
"@angular/core": "0.0.0-NG",
18+
"@angular/platform-server": "0.0.0-NG",
1919
"express": "^4.15.2"
2020
},
2121
"repository": {

modules/express-engine/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@angular/platform-server';
1818

1919
import { FileLoader } from './file-loader';
20-
import { REQUEST, RESPONSE } from '../tokens';
20+
import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
2121

2222
/**
2323
* These are the allowed options for the engine
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
export * from './public-api';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
export * from './tokens';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../tsconfig.lib",
3+
"files": [
4+
"public-api.ts"
5+
],
6+
"angularCompilerOptions": {
7+
"annotateForClosureCompiler": true,
8+
"strictMetadataEmit": false, // Workaround for Angular #22210
9+
"flatModuleOutFile": "index.js",
10+
"flatModuleId": "@nguniversal/express-engine/tokens",
11+
"skipTemplateCodegen": true,
12+
"fullTemplateTypeCheck": true
13+
}
14+
}

modules/express-engine/tsconfig.fortokens.json

-7
This file was deleted.

modules/express-engine/tsconfig.lib.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@
2121
"lib": ["es2015", "dom"],
2222
"skipLibCheck": true,
2323
"types": [],
24-
"baseUrl": "."
24+
"baseUrl": ".",
25+
"paths": {
26+
"@nguniversal/express-engine/*": ["../../dist/packages/express-engine/*"]
27+
}
2528
},
2629
"files": [
27-
"./public-api.ts"
30+
"public-api.ts"
2831
],
2932
"angularCompilerOptions": {
3033
"annotateForClosureCompiler": true,
31-
"strictMetadataEmit": true,
32-
"skipTemplateCodegen": true,
34+
"strictMetadataEmit": false, // Workaround for Angular #22210
3335
"flatModuleOutFile": "index.js",
34-
"flatModuleId": "@nguniversal/express-engine"
36+
"flatModuleId": "@nguniversal/express-engine",
37+
"skipTemplateCodegen": true,
38+
"fullTemplateTypeCheck": true
3539
}
3640
}

modules/express-engine/tsconfig.spec.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"types": ["jasmine"]
1111
},
1212
"angularCompilerOptions": {
13-
"strictMetadataEmit": true,
13+
"strictMetadataEmit": false, // Workaround for Angular #22210
1414
"skipTemplateCodegen": true,
1515
"emitDecoratorMetadata": true,
1616
"fullTemplateTypeCheck": true

0 commit comments

Comments
 (0)