Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

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

58 files changed

Lines changed: 1271 additions & 322 deletions

Some content is hidden

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

build-config.js

Lines changed: 2 additions & 2 deletions
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

Lines changed: 11 additions & 5 deletions
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

Lines changed: 13 additions & 5 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 21 additions & 12 deletions
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(
Lines changed: 8 additions & 0 deletions
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';
Lines changed: 8 additions & 0 deletions
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';
File renamed without changes.
Lines changed: 14 additions & 0 deletions
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

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)