Skip to content

Commit c7b48b8

Browse files
committed
Update build process to work with Angular 5 compiler-cli.
1 parent 7422e1f commit c7b48b8

18 files changed

+564
-540
lines changed

build.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Modified from angular-quickstart-lib
2+
// https://github.com/filipesilva/angular-quickstart-lib/blob/master/build.js
3+
14
'use strict';
25

36
const fs = require('fs');
@@ -28,15 +31,13 @@ return Promise.resolve()
2831
.then(() => console.log('Inlining succeeded.'))
2932
)
3033
// Compile to ES2015.
31-
.then(() => ngc({ project: `${tempLibFolder}/tsconfig.json` })
34+
.then(() => ngc(['--project', `${tempLibFolder}/tsconfig.json`]))
3235
.then(exitCode => exitCode === 0 ? Promise.resolve() : Promise.reject())
3336
.then(() => console.log('ES2015 compilation succeeded.'))
34-
)
3537
// Compile to ES5.
36-
.then(() => ngc({ project: `${tempLibFolder}/tsconfig.es5.json` })
38+
.then(() => ngc(['--project', `${tempLibFolder}/tsconfig.es5.json`]))
3739
.then(exitCode => exitCode === 0 ? Promise.resolve() : Promise.reject())
3840
.then(() => console.log('ES5 compilation succeeded.'))
39-
)
4041
// Copy typings and metadata to `dist/` folder.
4142
.then(() => Promise.resolve()
4243
.then(() => _relativeCopy('**/*.d.ts', es2015OutputFolder, distFolder))
@@ -133,10 +134,6 @@ return Promise.resolve()
133134
})
134135
});
135136

136-
// return rollup.rollup(fesm5config.input)
137-
// .then(bundle => bundle.write(fesm5config.output))
138-
// .then(() => console.log('fesm5config bundle generated successfully.'));
139-
// console.log(umdConfig, minifiedUmdConfig, fesm5config, fesm2015config);
140137
const allBundles = [umdConfig, minifiedUmdConfig, fesm5config, fesm2015config]
141138
.map(cfg => rollup.rollup(cfg).then(bundle => bundle.write(cfg.output)));
142139

inline-resources.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const writeFile = promiseify(fs.writeFile);
2525

2626
/**
2727
* Inline resources in a tsc/ngc compilation.
28-
* @param projectPath {string} Path to the project.
28+
* @param { string } projectPath Path to the project.
2929
*/
3030
function inlineResources(projectPath) {
3131

@@ -41,17 +41,15 @@ function inlineResources(projectPath) {
4141
return path.join(path.dirname(fullFilePath), url);
4242
}))
4343
.then(content => writeFile(fullFilePath, content))
44-
.catch(err => {
45-
console.error('An error occured: ', err);
46-
});
44+
.catch(err => console.error('An error occured: ', err));
4745
}));
4846
}
4947

5048
/**
5149
* Inline resources from a string content.
52-
* @param content {string} The source file's content.
53-
* @param urlResolver {Function} A resolver that takes a URL and return a path.
54-
* @returns {string} The content with resources inlined.
50+
* @param { string } content The source file's content.
51+
* @param { Function } urlResolver A resolver that takes a URL and return a path.
52+
* @return { string } The content with resources inlined.
5553
*/
5654
function inlineResourcesFromString(content, urlResolver) {
5755
// Curry through the inlining functions.
@@ -63,11 +61,12 @@ function inlineResourcesFromString(content, urlResolver) {
6361
}
6462

6563
/**
66-
* Inline the templates for a source file. Simply search for instances of `templateUrl: ...` and
67-
* replace with `template: ...` (with the content of the file included).
68-
* @param content {string} The source file's content.
69-
* @param urlResolver {Function} A resolver that takes a URL and return a path.
70-
* @return {string} The content with all templates inlined.
64+
* Inline the templates for a source file.
65+
* Search for instances of `templateUrl: ...` and replace with `template: ...`
66+
* (with the content of the file included).
67+
* @param { string } content The source file's content.
68+
* @param { Function } urlResolver A resolver that takes a URL and return a path.
69+
* @return { string } The content with all templates inlined.
7170
*/
7271
function inlineTemplate(content, urlResolver) {
7372
return content.replace(/templateUrl:\s*'([^']+?\.html)'/g, function (m, templateUrl) {
@@ -83,9 +82,9 @@ function inlineTemplate(content, urlResolver) {
8382
/**
8483
* Inline the styles for a source file. Search for instances of `styleUrls: [...]`
8584
* and replace with `styles: [...]` (with the content of the file included).
86-
* @param urlResolver {Function} A resolver that takes a URL and return a path.
87-
* @param content {string} The source file's content.
88-
* @return {string} The content with all styles inlined.
85+
* @param { Function } urlResolver A resolver that takes a URL and return a path.
86+
* @param { string } content The source file's content.
87+
* @return { string } The content with all styles inlined.
8988
*/
9089
function inlineStyle(content, urlResolver) {
9190
return content.replace(/styleUrls:\s*(\[[\s\S]*?\])/gm, function (m, styleUrls) {
@@ -104,8 +103,8 @@ function inlineStyle(content, urlResolver) {
104103

105104
/**
106105
* Remove every mention of `moduleId: module.id`.
107-
* @param content {string} The source file's content.
108-
* @returns {string} The content with all moduleId: mentions removed.
106+
* @param { string } content The source file's content.
107+
* @return { string } The content with all moduleId: mentions removed.
109108
*/
110109
function removeModuleId(content) {
111110
return content.replace(/\s*moduleId:\s*module\.id\s*,?\s*/gm, '');

0 commit comments

Comments
 (0)