-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal: remove usage of hand crafted webpack typings #927
Conversation
src/after-compile.ts
Outdated
@@ -16,14 +16,24 @@ import { | |||
isUsingProjectReferences | |||
} from './utils'; | |||
|
|||
interface PatchedCompiler extends webpack.Compiler { |
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.
Bug #1 where the following properties are not available on a compiler instance.
src/instances.ts
Outdated
@@ -29,6 +29,9 @@ import { makeWatchRun } from './watch-run'; | |||
|
|||
const instances = {} as TSInstances; | |||
|
|||
// TODO: workaround for issues with webpack typings | |||
type PatchedHookCallback = any; |
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.
e162193
to
2cbbdf3
Compare
Nice! I've merged the changes in definitely typed... Let's see where this goes! 😀 |
I think we just merged them in the wrong place facepalm Moved to the correct place: DefinitelyTyped/DefinitelyTyped#35056 |
Merged! |
Updated the PR with the latest typings package! Passes locally for me, so should be good once Travis passes. |
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.
if (existingModules.indexOf(module) === -1) { | ||
existingModules.push(module); | ||
function determineModules(compilation: webpack.compilation.Compilation) { | ||
return compilation.modules.reduce<Map<string, WebpackModule[]>>( |
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.
Nice!
@@ -7,10 +7,6 @@ export const LineFeed = '\n'; | |||
export const CarriageReturnLineFeedCode = 0; | |||
export const LineFeedCode = 1; | |||
|
|||
export const ScriptTargetES2015 = 2; |
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.
So interestingly the moving of using locally defined constants to directly depending on TypeScript would mark the first direct runtime (rather than compilation time) dependency on the typescript
module. All the others (I think) are type dependencies.
I believe, back in the mists of time, this was an intentional choice by ts-loader's @jbrantly. I think the reasons were to do with ts-loader working with multiple versions of TypeScript - not bolted to a specific one that you build with. It may been related to the ability to supply your own version of TypeScript. Remember ntypescript?
https://github.com/TypeStrong/ts-loader/blob/master/README.md#compiler-string-defaulttypescript
See also:
ts-loader/src/compilerSetup.ts
Line 15 in 48626a9
compiler = require(loaderOptions.compiler); |
I don't know if this matters anymore. The values of those enums are pretty much set in stone now.
I'd appreciate any thoughts on this - it's probably fine. But I've a feeling that other views may be available too.
Also @arcanis - would this create issues for yarn PnP support?
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.
Also @arcanis - would this create issues for yarn PnP support?
Not if typescript
is defined as either dependencies
or peerDependencies
(devDependencies
won't do since they won't be considered part of the dependency tree when installed by consumers).
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.
Cool - it's already a peerDependency
so I guess we're good
Line 94 in 48626a9
"peerDependencies": { |
"peerDependencies": {
"typescript": "*"
}
So I think we're good to merge and ship! Could you update the |
Will do! |
Done! |
Nice! Thanks for your work! ❤️ |
Should be released shortly https://github.com/TypeStrong/ts-loader/releases/tag/v5.4.5 |
Some tidy up of the internals to use the
@types/webpack
webpack package for webpack specific typings.As far as I can see there are two bugs in the webpack typings which I'll try and upstream: DefinitelyTyped/DefinitelyTyped#35053