Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

feat(@ngtools/webpack): resolve all file requests with the virtual fs #887

Merged
merged 2 commits into from
May 15, 2018

Conversation

sis0k0
Copy link
Contributor

@sis0k0 sis0k0 commented May 10, 2018

fixes #885

@@ -18,17 +18,16 @@ export class VirtualFileSystemDecorator implements InputFileSystem {
private _webpackCompilerHost: WebpackCompilerHost,
) { }

// We only need to intercept calls to individual files that are present in WebpackCompilerHost.
private _readFileSync(path: string): string | null {
Copy link
Member

@clydin clydin May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack filesystems return a Buffer not a string. This will break any file type that is not text (e.g., JPG, WOFF, etc.) or uses non-default text encoding (i.e., not UTF8 without a BOM).

This only currently works because only source code is returned from the host which is known text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I'll keep digging into that. Do you have some ideas we might try?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Unfortunately, it is a decent amount of work. The WebpackCompilerHost would need to be refactored to internally use Buffer objects to store the data and then convert to strings where needed inside the WebpackCompilerHost. And then provide Buffer return objects for the read calls within the webpack filesystem decorators.

@sis0k0 sis0k0 force-pushed the sis0k0/vfs-patch branch from 259f437 to 5e9eed5 Compare May 11, 2018 20:36
@sis0k0
Copy link
Contributor Author

sis0k0 commented May 13, 2018

Hey @clydin,

I've modified the VirtualFileStats class. Now it can be instantiated either with content of type string, or content of type BufferArray. The other value is generated when needed. Also, some tests are failing/timing out in CircleCI, but they pass locally.

@sis0k0 sis0k0 changed the title fix(@ngtools/webpack): resolve all file requests with the virtual fs feat(@ngtools/webpack): resolve all file requests with the virtual fs May 14, 2018
@sis0k0 sis0k0 force-pushed the sis0k0/vfs-patch branch from 5e9eed5 to d806d0e Compare May 15, 2018 12:01
@sis0k0
Copy link
Contributor Author

sis0k0 commented May 15, 2018

Rebasing on top of master fixed the builds. 10x for the suggestion, @filipesilva :)

@Brocco Brocco merged commit be24fed into angular:master May 15, 2018
@hansl
Copy link
Contributor

hansl commented May 15, 2018

FYI this is a feature and will not be released until 6.1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File replacements work only for TypeScript files
5 participants