Skip to content
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

Compile bundled files and typing files #671

Merged

Conversation

maier49
Copy link
Contributor

@maier49 maier49 commented Oct 25, 2017

This PR adds a flag that modifies the behavior of ts-loader so that it only loads files that are bundled by webpack and any .d.ts files that match the config in tsconfig.json. This is an attempt to implement the behavior described in #267, or at least a starting point.

The approach is very simple and I can't help but feel like there's some obvious issue with it that I'm not thinking of, but it seems to work fine in the test case I created at least. The reason for compiling all .d.ts files as well as bundled files is that they may include types that are used in files that are bundled without being explicitly imported. Attempting to determine exactly which files are needed seems like it may be quite difficult and potentially slow.

@johnnyreilly
Copy link
Member

Awesome - thanks for this! I'll try and take a look later on. BTW we only need comparison test output for the latest released version of TypeScript (2.5 right now). I really should make that clearer in the docs!

src/index.ts Outdated
@@ -110,7 +110,7 @@ function getLoaderOptions(loader: Webpack) {
}

type ValidLoaderOptions = keyof LoaderOptions;
const validLoaderOptions: ValidLoaderOptions[] = ['silent', 'logLevel', 'logInfoToStdOut', 'instance', 'compiler', 'configFile', 'transpileOnly', 'ignoreDiagnostics', 'errorFormatter', 'colors', 'compilerOptions', 'appendTsSuffixTo', 'appendTsxSuffixTo', 'entryFileCannotBeJs' /* DEPRECATED */, 'happyPackMode', 'getCustomTransformers'];
const validLoaderOptions: ValidLoaderOptions[] = ['silent', 'logLevel', 'logInfoToStdOut', 'instance', 'compiler', 'configFile', 'transpileOnly', 'ignoreDiagnostics', 'errorFormatter', 'colors', 'compilerOptions', 'appendTsSuffixTo', 'appendTsxSuffixTo', 'entryFileCannotBeJs', 'onlyCompileBundledFiles' /* DEPRECATED */, 'happyPackMode', 'getCustomTransformers'];
Copy link
Member

Choose a reason for hiding this comment

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

Please can you move /* DEPRECATED */ back to after 'entryFileCannotBeJs?

@johnnyreilly
Copy link
Member

Generally this looks good - could you remove comparison test output apart from 2.5? Also could you add something to the README about the new option?

Remove unnecessary expected output for tests

Add documentation on the option to the README

Fix location of a comment in src/index.ts
@maier49
Copy link
Contributor Author

maier49 commented Oct 25, 2017

@johnnyreilly Thanks for the quick review. I made some updates to address your comments.

@johnnyreilly
Copy link
Member

Sweet - I'll try and take a look tomorrow. Thanks!

@johnnyreilly
Copy link
Member

Perfect!

@johnnyreilly
Copy link
Member

Hope to ship this with ts-loader 3.1.0

qazbnm456 added a commit to LulumiProject/lulumi-browser that referenced this pull request Oct 31, 2017
qazbnm456 added a commit to LulumiProject/lulumi-browser that referenced this pull request Oct 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants