-
-
Notifications
You must be signed in to change notification settings - Fork 430
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
node modules subdir #365
node modules subdir #365
Conversation
[0] ./.test/node_modules-subdir/app.ts 62 bytes {0} [built] [1 error] | ||
|
||
ERROR in ./.test/node_modules-subdir/~/foo/bar/index.ts |
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 not error
Traced the bug to TypeScript. Modified the language service function getEmitOutput(fileName, emitDeclarationsOnly) {
synchronizeHostData();
var sourceFile = getValidSourceFile(fileName);
var outputFiles = [];
function writeFile(fileName, data, writeByteOrderMark) {
outputFiles.push({
name: fileName,
writeByteOrderMark: writeByteOrderMark,
text: data
});
}
var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitDeclarationsOnly);
if (fileName.lastIndexOf('lib') == -1) {
console.log('getEmitOutput'.magenta, fileName, outputFiles.length)
console.log(sourceFile.getFullText())
}
return {
outputFiles: outputFiles,
emitSkipped: emitOutput.emitSkipped
};
} And in the log I can see that it outputs nothing even though it sees some input text:
Will investigate more later |
Got it. Its the function The function body is super simple: function forEachExpectedEmitFile(host, action, targetSourceFile, emitOnlyDtsFiles) {
console.log(targetSourceFile.fileName.red, {external:host.isSourceFileFromExternalLibrary(targetSourceFile)}); // My addition
var options = host.getCompilerOptions();
// Emit on each source file
if (options.outFile || options.out) {
onBundledEmit(host);
}
else {
var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) {
var sourceFile = sourceFiles_1[_i];
// Don't emit if source file is a declaration file, or was located under node_modules
if (!isDeclarationFile(sourceFile) && !host.isSourceFileFromExternalLibrary(sourceFile)) {
onSingleFileEmit(host, sourceFile);
}
}
} Basically Seems intentional in the TypeScript's design to not allow external libraries to ship |
Thinking this through, for our (ts-loader) host, |
Wow! I go to do nursery drop off and check my phone to find this. Good work @basarat :+100: 🌷 |
Closing since I think its a bad idea to have the need to transpile |
refs #278
Run as
npm run comparison-tests -- --single-test node_modules-subdir
Or cd into test dir, edit
webpack.config.js
in the test dir to have an additional..
and run aswebpack
in the test dir (withnpm install webpack -g
)