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

Commit

Permalink
build(lib): fix secondary entrypoints and bundle with APF v5 (#940)
Browse files Browse the repository at this point in the history
* Revert back to APF bundling to resolve build issues
* Incorporate Material build system to handle secondary entrypoints
  and bundling
  • Loading branch information
CaerusKaru authored and vikerman committed Mar 23, 2018
1 parent 24adea6 commit ce1baff
Show file tree
Hide file tree
Showing 58 changed files with 1,271 additions and 322 deletions.
4 changes: 2 additions & 2 deletions build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const buildLicense = `/**
*/`;

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

/** The library entrypoints that are built under the namespace */
const libNames = [
Expand All @@ -40,7 +40,7 @@ module.exports = {
projectVersion: buildVersion,
angularVersion: angularVersion,
projectDir: __dirname,
packagesDir: join(__dirname, 'src'),
packagesDir: join(__dirname, 'modules'),
outputDir: join(__dirname, 'dist'),
licenseBanner: buildLicense,
namespace,
Expand Down
16 changes: 11 additions & 5 deletions build-test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import {buildConfig, buildLib} from './tools/package-tools';
import {buildConfig, BuildPackage, packages} from './tools/package-tools';

declare var require: any;

const rimraf = require('rimraf');

const buildPkg = async (pkg: BuildPackage) => {
pkg.dependencies.forEach(buildPkg);
await pkg.compileTests();
};


rimraf(buildConfig.outputDir, async () => {
for (const lib of buildConfig.libNames) {
const exitCode = await buildLib(lib, true);
console.log(exitCode === 0 ? `Build succeeded for ${lib}` : `Build failed for ${lib}`);
console.log();
for (const pkg of packages) {
console.log(`Building package to test: ${pkg.name}`);
await buildPkg(pkg);
console.log(`Finished building: ${pkg.name}`);
}
});
18 changes: 13 additions & 5 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import {buildConfig, buildLib} from './tools/package-tools';
import {buildConfig, BuildPackage, composeRelease, packages} from './tools/package-tools';

declare var require: any;

const rimraf = require('rimraf');

const buildPkg = async (pkg: BuildPackage) => {
pkg.dependencies.forEach(buildPkg);
await pkg.compile();
await pkg.createBundles();
};


rimraf(buildConfig.outputDir, async () => {
for (const lib of buildConfig.libNames) {
const exitCode = await buildLib(lib);
console.log(exitCode === 0 ? `Build succeeded for ${lib}` : `Build failed for ${lib}`);
console.log();
for (const pkg of packages) {
console.log(`Building package: ${pkg.name}`);
await buildPkg(pkg);
composeRelease(pkg);
console.log(`Finished building: ${pkg.name}`);
}
});
6 changes: 3 additions & 3 deletions modules/aspnetcore-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nguniversal/aspnetcore-engine",
"version": "5.0.0-beta.6",
"version": "0.0.0-PLACEHOLDER",
"description": "ASP.NET Core Engine for running Server Angular Apps",
"main": "./bundles/aspnetcore-engine.umd.js",
"module": "./esm5/aspnetcore-engine.es5.js",
Expand All @@ -21,8 +21,8 @@
"universal"
],
"peerDependencies": {
"@angular/common": "^5.0.0",
"@angular/core": "^5.0.0"
"@angular/common": "0.0.0-NG",
"@angular/core": "0.0.0-NG"
},
"repository": {
"type": "git",
Expand Down
33 changes: 21 additions & 12 deletions modules/aspnetcore-engine/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* 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 { Type, NgModuleFactory, CompilerFactory, Compiler } from '@angular/core';
import {Type, NgModuleFactory, CompilerFactory, Compiler, StaticProvider} from '@angular/core';
import { platformDynamicServer } from '@angular/platform-server';
import { DOCUMENT } from '@angular/common';
import { ResourceLoader } from '@angular/compiler';

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

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

const extraProviders = options.providers.concat(
[{
provide: ORIGIN_URL,
useValue: options.request.origin
}, {
provide: REQUEST,
useValue: options.request.data.request
}
]
);
const extraProviders = options.providers.concat(getReqResProviders(options.request.origin,
options.request.data.request));

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

}

/**
* Get providers of the request and response
*/
function getReqResProviders(origin: string, request: string): StaticProvider[] {
const providers: StaticProvider[] = [
{
provide: ORIGIN_URL,
useValue: origin
},
{
provide: REQUEST,
useValue: request
}
];
return providers;
}

/* @internal */
const factoryCacheMap = new Map<Type<{}>, NgModuleFactory<{}>>();
function getFactory(
Expand Down
8 changes: 8 additions & 0 deletions modules/aspnetcore-engine/tokens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright Google LLC 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
*/
export * from './public-api';
8 changes: 8 additions & 0 deletions modules/aspnetcore-engine/tokens/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright Google LLC 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
*/
export * from './tokens';
14 changes: 14 additions & 0 deletions modules/aspnetcore-engine/tokens/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.lib",
"files": [
"public-api.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"flatModuleOutFile": "index.js",
"flatModuleId": "@nguniversal/aspnetcore-engine/tokens",
"skipTemplateCodegen": true,
"fullTemplateTypeCheck": true
}
}
7 changes: 0 additions & 7 deletions modules/aspnetcore-engine/tsconfig.fortokens.json

This file was deleted.

14 changes: 9 additions & 5 deletions modules/aspnetcore-engine/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
"lib": ["es2015", "dom"],
"skipLibCheck": true,
"types": ["node"],
"baseUrl": "."
"baseUrl": ".",
"paths": {
"@nguniversal/aspnetcore-engine/*": ["../../dist/packages/aspnetcore-engine/*"]
}
},
"files": [
"./public-api.ts"
"public-api.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"flatModuleOutFile": "index.js",
"flatModuleId": "@nguniversal/aspnetcore-engine"
"flatModuleId": "@nguniversal/aspnetcore-engine",
"skipTemplateCodegen": true,
"fullTemplateTypeCheck": true
}
}
2 changes: 1 addition & 1 deletion modules/aspnetcore-engine/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types": ["jasmine", "node"]
},
"angularCompilerOptions": {
"strictMetadataEmit": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"skipTemplateCodegen": true,
"emitDecoratorMetadata": true,
"fullTemplateTypeCheck": true
Expand Down
6 changes: 3 additions & 3 deletions modules/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nguniversal/common",
"version": "5.0.0-beta.6",
"version": "0.0.0-PLACEHOLDER",
"description": "Angular Universal common utilities",
"main": "./bundles/common.umd.js",
"module": "./esm5/common.es5.js",
Expand All @@ -12,8 +12,8 @@
"universal"
],
"peerDependencies": {
"@angular/common": "^5.0.0",
"@angular/core": "^5.0.0"
"@angular/common": "0.0.0-NG",
"@angular/core": "0.0.0-NG"
},
"repository": {
"type": "git",
Expand Down
14 changes: 9 additions & 5 deletions modules/common/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
"lib": ["es2015", "dom"],
"skipLibCheck": true,
"types": [],
"baseUrl": "."
"baseUrl": ".",
"paths": {
"@nguniversal/common/*": ["../../dist/packages/common/*"]
}
},
"files": [
"./public-api.ts"
"public-api.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"flatModuleOutFile": "index.js",
"flatModuleId": "@nguniversal/common"
"flatModuleId": "@nguniversal/common",
"skipTemplateCodegen": true,
"fullTemplateTypeCheck": true
}
}
2 changes: 1 addition & 1 deletion modules/common/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types": ["jasmine"]
},
"angularCompilerOptions": {
"strictMetadataEmit": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"skipTemplateCodegen": true,
"emitDecoratorMetadata": true,
"fullTemplateTypeCheck": true
Expand Down
8 changes: 4 additions & 4 deletions modules/express-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nguniversal/express-engine",
"version": "5.0.0-beta.6",
"version": "0.0.0-PLACEHOLDER",
"description": "Express Engine for running Server Angular Apps",
"main": "./bundles/express-engine.umd.js",
"module": "./esm5/express-engine.es5.js",
Expand All @@ -13,9 +13,9 @@
"universal"
],
"peerDependencies": {
"@angular/common": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/common": "0.0.0-NG",
"@angular/core": "0.0.0-NG",
"@angular/platform-server": "0.0.0-NG",
"express": "^4.15.2"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion modules/express-engine/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@angular/platform-server';

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

/**
* These are the allowed options for the engine
Expand Down
8 changes: 8 additions & 0 deletions modules/express-engine/tokens/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright Google LLC 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
*/
export * from './public-api';
8 changes: 8 additions & 0 deletions modules/express-engine/tokens/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright Google LLC 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
*/
export * from './tokens';
File renamed without changes.
14 changes: 14 additions & 0 deletions modules/express-engine/tokens/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../tsconfig.lib",
"files": [
"public-api.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"flatModuleOutFile": "index.js",
"flatModuleId": "@nguniversal/express-engine/tokens",
"skipTemplateCodegen": true,
"fullTemplateTypeCheck": true
}
}
7 changes: 0 additions & 7 deletions modules/express-engine/tsconfig.fortokens.json

This file was deleted.

14 changes: 9 additions & 5 deletions modules/express-engine/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
"lib": ["es2015", "dom"],
"skipLibCheck": true,
"types": [],
"baseUrl": "."
"baseUrl": ".",
"paths": {
"@nguniversal/express-engine/*": ["../../dist/packages/express-engine/*"]
}
},
"files": [
"./public-api.ts"
"public-api.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"flatModuleOutFile": "index.js",
"flatModuleId": "@nguniversal/express-engine"
"flatModuleId": "@nguniversal/express-engine",
"skipTemplateCodegen": true,
"fullTemplateTypeCheck": true
}
}
2 changes: 1 addition & 1 deletion modules/express-engine/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types": ["jasmine"]
},
"angularCompilerOptions": {
"strictMetadataEmit": true,
"strictMetadataEmit": false, // Workaround for Angular #22210
"skipTemplateCodegen": true,
"emitDecoratorMetadata": true,
"fullTemplateTypeCheck": true
Expand Down
Loading

0 comments on commit ce1baff

Please sign in to comment.