-
Notifications
You must be signed in to change notification settings - Fork 155
Conversation
e347e78
to
a39684c
Compare
// TODO: fix webpack typings. | ||
// tslint:disable-next-line:no-any | ||
(webpackCompiler as any).inputFileSystem = new WebpackFileSystemHostAdapter( | ||
new NodeJsSyncHost(), |
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.
Shouldn't this be using the this.context.host
instead of a new one? Or at least one based on the that one.
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.
Yes it should. Sorry I'll fix it. I tried it and it was failing, so decided to focus on one error at a time. Since all paths are absolute not to the Host but to the file system, that's a deeper change in general.
|
||
readFile(path: string, callback: Callback<Buffer>): void { | ||
const o = this._host.read(normalize('/' + path)).pipe( | ||
map(content => new Buffer(content)), |
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.
This should be mapped to string via virtualFs.fileBufferToString
.
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.
Actually the webpack adapter wants to have node Buffers as a return, because it expects this to match the fs
interface.
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.
Oh, I didn't know that. In the ngtools/webpack FS we return the string. Maybe that's broken there.
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.
It's not broken for source files. The only thing Webpack is doing is toString('utf-8')
, which works for strings 🤷
} | ||
|
||
readlink(path: string, callback: Callback<string>): void { | ||
const err: NodeJS.ErrnoException = new Error('Not a symlink.'); |
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.
We should support symlinks in the future.
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.
I disagree, at least as far as the host is concerned, symlinks were intentionally left out of the design.
We "support" them by having the Node*Host supports proper stats and you check them, but if you don't know which host comes in then you cannot know (and shouldn't IMO).
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.
Ok, I don't have any usecase that needs them right now either.
} | ||
|
||
readdir(path: string, callback: Callback<string[]>): void { | ||
return this._doHostCall(this._host.list(normalize('/' + path)), callback); |
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.
I think this will need to return the system paths instead of the normalized Paths
.
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.
Maybe as input, but readdir
returns fragments which do not contain slashes.
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.
Good point.
throw err; | ||
} | ||
|
||
purge(_changes?: string[] | string): void {} |
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.
This will need to be implemented in the future.
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.
I'm not sure what this should do for our own adapter. For a cache system you can clear the cache, but here I don't thikn there's anything to do. purge
is optional on the real typings btw.
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.
Let's leave it off and see if there's any problem then.
07a9203
to
c796862
Compare
stat(_path: Path): Observable<Stats<{}>> | null { | ||
return null; | ||
// Some hosts may not support stat. | ||
stat(path: Path): Observable<Stats<{}>> { |
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.
Observable<Stats>
?
|
||
return observableOf(this._cache.has(path) || this._isDir(path)); | ||
list(path: Path): Observable<PathFragment[]> { |
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.
Thoughts on this returning Observable<PathFragment>
instead of the array. Would allow the consumer to operator on the stream of elements directly.
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.
I see Observable<X>
here as a replacement of Promise<>
. The contract is that these will always emit once and complete, or error out. I like the consistence of this interface too.
return new Observable(obs => { | ||
// Create folders if necessary. | ||
const _createDir = (path: Path) => { | ||
if (fs.existsSync(getSystemPath(path))) { |
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.
Probably a refactor for the future but for all the sync calls could we use the async versions with utils.promisify
and convert and return the observabled promise?
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.
You mean the async ones? The sync ones need to be sync.
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.
Yes. Sorry for the confusion.
|
||
// TODO: fix webpack typings. | ||
// tslint:disable-next-line:no-any | ||
(webpackCompiler as any).inputFileSystem = new WebpackFileSystemHostAdapter( |
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.
The watch file system will be unaffected and I don't think caching will be used. This webpack plugin is always applied before anything else: https://github.com/webpack/webpack/blob/master/lib/node/NodeEnvironmentPlugin.js
https://github.com/webpack/webpack/blob/master/lib/webpack.js#L34
@@ -56,29 +56,29 @@ export function gatherDiagnostics( | |||
const tsProgram = program as ts.Program; | |||
// Check syntactic diagnostics. | |||
time(`${benchmarkLabel}.gatherDiagnostics.ts.getSyntacticDiagnostics`); | |||
checkDiagnostics(tsProgram.getSyntacticDiagnostics); | |||
checkDiagnostics(tsProgram.getSyntacticDiagnostics.bind(tsProgram)); |
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.
() => tsProgram.getSyntacticDiagnostics()
?
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.
Yeah that looks better imho.
@@ -87,6 +88,8 @@ export interface AngularCompilerPluginOptions { | |||
|
|||
// Use tsconfig to include path globs. | |||
compilerOptions?: ts.CompilerOptions; | |||
|
|||
host: virtualFs.Host<fs.Stats>; |
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.
optional?
…which is more correct And fits with the rest of the fs methods.
c880b24
to
0bcf4f8
Compare
@@ -31,7 +32,7 @@ export function runTargetSpec( | |||
host: TestProjectHost, | |||
targetSpec: TargetSpecifier, | |||
overrides = {}, | |||
logger: logging.Logger = new logging.NullLogger(), | |||
logger: logging.Logger = createConsoleLogger(), |
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.
This change should be reverted.
I will followup this PR with fixes for the Windows CI. |
No description provided.