This repository was archived by the owner on Sep 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
upgrade to typescript 2.0 and fix broken build process #47
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4eee692
upgrade tslint & typescript for 2.0 and fix broken build process
015d56a
use new tsconfig includes syntax
f5cada9
migrate vinyl-fs & fs-extra custom type definitions to npm type defin…
18020ae
catch errors within then() call for service-worker tests
9e1a193
fix silly depcheck error
67c86f8
Add sw-precache custom_typing declaration reference
10b4fc2
small fix to test structure
75a531f
generate type declarations via gulp build
9f151bd
Remove tsconfig files array
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,68 +104,65 @@ export class Bundler extends Transform { | |
| return this.allFragments.indexOf(file.path) !== -1; | ||
| } | ||
|
|
||
| _buildBundles(): Promise<Map<string, string>> { | ||
| return this._getBundles().then((bundles) => { | ||
| let sharedDepsBundle = (this.shell) | ||
| ? urlFromPath(this.root, this.shell) | ||
| : this.sharedBundleUrl; | ||
| let sharedDeps = bundles.get(sharedDepsBundle) || []; | ||
| let promises: Promise<any>[] = []; | ||
|
|
||
| if (this.shell) { | ||
| let shellFile = this.analyzer.getFile(this.shell); | ||
| console.assert(shellFile != null); | ||
| let newShellContent = this._addSharedImportsToShell(bundles); | ||
| shellFile.contents = new Buffer(newShellContent); | ||
| } | ||
| async _buildBundles(): Promise<Map<string, string>> { | ||
| let bundles = await this._getBundles(); | ||
| let sharedDepsBundle = (this.shell) | ||
| ? urlFromPath(this.root, this.shell) | ||
| : this.sharedBundleUrl; | ||
| let sharedDeps = bundles.get(sharedDepsBundle) || []; | ||
| let promises: Promise<any>[] = []; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minimize use of const promises: Promise<{url: string, contents: string}>[] = []
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, but I'd like to keep the scope of this PR small for now. This diff was only a indentation change due to a move over to async-await above. I'll make a separate PR to address this. |
||
|
|
||
| if (this.shell) { | ||
| let shellFile = this.analyzer.getFile(this.shell); | ||
| console.assert(shellFile != null); | ||
| let newShellContent = this._addSharedImportsToShell(bundles); | ||
| shellFile.contents = new Buffer(newShellContent); | ||
| } | ||
|
|
||
| for (let fragment of this.allFragments) { | ||
| let fragmentUrl = urlFromPath(this.root, fragment); | ||
| let addedImports = (fragment === this.shell && this.shell) | ||
| ? [] | ||
| : [posixPath.relative(posixPath.dirname(fragmentUrl), sharedDepsBundle)]; | ||
| let excludes = (fragment === this.shell && this.shell) | ||
| ? [] | ||
| : sharedDeps.concat(sharedDepsBundle); | ||
|
|
||
| promises.push(new Promise((resolve, reject) => { | ||
| let vulcanize = new Vulcanize({ | ||
| abspath: null, | ||
| fsResolver: this.analyzer.resolver, | ||
| addedImports: addedImports, | ||
| stripExcludes: excludes, | ||
| inlineScripts: true, | ||
| inlineCss: true, | ||
| inputUrl: fragmentUrl, | ||
| }); | ||
| vulcanize.process(null, (err: any, doc: string) => { | ||
| if (err) { | ||
| reject(err); | ||
| } else { | ||
| resolve({ | ||
| url: fragment, | ||
| contents: doc, | ||
| }); | ||
| } | ||
| }); | ||
| })); | ||
| } | ||
| // vulcanize the shared bundle | ||
| if (!this.shell && sharedDeps && sharedDeps.length !== 0) { | ||
| logger.info(`generating shared bundle...`); | ||
| promises.push(this._generateSharedBundle(sharedDeps)); | ||
| } | ||
| return Promise.all(promises).then((bundles) => { | ||
| // TODO(justinfagnani): remove at TypeScript 2.0 | ||
| let _bundles = <any[]>bundles; | ||
| // convert {url,contents}[] into a Map | ||
| let contentsMap = new Map(); | ||
| for (let bundle of _bundles) { | ||
| contentsMap.set(bundle.url, bundle.contents); | ||
| } | ||
| return contentsMap; | ||
| }); | ||
| }); | ||
| for (let fragment of this.allFragments) { | ||
| let fragmentUrl = urlFromPath(this.root, fragment); | ||
| let addedImports = (fragment === this.shell && this.shell) | ||
| ? [] | ||
| : [posixPath.relative(posixPath.dirname(fragmentUrl), sharedDepsBundle)]; | ||
| let excludes = (fragment === this.shell && this.shell) | ||
| ? [] | ||
| : sharedDeps.concat(sharedDepsBundle); | ||
|
|
||
| promises.push(new Promise((resolve, reject) => { | ||
| let vulcanize = new Vulcanize({ | ||
| abspath: null, | ||
| fsResolver: this.analyzer.resolver, | ||
| addedImports: addedImports, | ||
| stripExcludes: excludes, | ||
| inlineScripts: true, | ||
| inlineCss: true, | ||
| inputUrl: fragmentUrl, | ||
| }); | ||
| vulcanize.process(null, (err: any, doc: string) => { | ||
| if (err) { | ||
| reject(err); | ||
| } else { | ||
| resolve({ | ||
| url: fragment, | ||
| contents: doc, | ||
| }); | ||
| } | ||
| }); | ||
| })); | ||
| } | ||
|
|
||
| // vulcanize the shared bundle | ||
| if (!this.shell && sharedDeps && sharedDeps.length !== 0) { | ||
| logger.info(`generating shared bundle...`); | ||
| promises.push(this._generateSharedBundle(sharedDeps)); | ||
| } | ||
|
|
||
| let vulcanizedBundles = await Promise.all(promises); | ||
| let contentsMap = new Map(); | ||
| for (let bundle of vulcanizedBundles) { | ||
| contentsMap.set(bundle.url, bundle.contents); | ||
| } | ||
| return contentsMap; | ||
| } | ||
|
|
||
| _addSharedImportsToShell(bundles: Map<string, string[]>): string { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and elsewhere: preferred style is
constby default,letonly when necessary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but I'd like to keep the scope of this PR small for now. I'll make a separate PR to address this across the repo once this has been merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed w/ the agree. In the future, just do the async/await in another PR also :)