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.
The issue fixed here is that the typescript loader loads typescript using a dynamic require in https://github.com/TypeStrong/ts-loader/blob/master/src/compilerSetup.ts#L15.
This is fixed using the previous dynamic require technique of allowing webpack to support a numeric
require
wherecompiler
is simply the numericrequire.resolve('typescript')
replacement provided by Webpack.We do this by patching the empty context module to attempt to load that numeric id when it can.
With this fixed, the remaining bug was that TypeScript loads its own types from the
lib
directory, but with logic that isn't statically analyzable by ncc, something like the following:where the asset emission would work if the above was
path.join(__dirname, 'lib', libFileName)
but doesn't work here because we can't statically analyze eitherdefaultLibraryPath
,libFileName
orts.combinePaths
.The work-around here was just like the webpack builtins - to manually relocate the
lib
folder into the ncc dist folder, which surprisingly then all seems to work out ok.It would be worth testing it further though with various configurations to be sure...