-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
No longer possible to use different loader options for different files #1102
Comments
Thanks for the detailed issue - that's very helpful! Would you like to submit a PR? |
I have submitted a PR. The updated code passes the execution tests and also works in my application, which depends on this behaviour. I note that the comparison tests don't work since 7.0.1. |
I have generated a new pull request including an execution test. While working on this I found that my previous patch was not sufficient if the changed options were functions (such as getCustomTransformers) as these are only attached when a new instance is created. I also found that an option already exists to manage this behaviour, the 'instance' option. However, it is easy to miss that this is necessary so my new pull request automatically creates a new instance whenever the options change. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
Expected Behaviour
It should be possible to specify different options for each file type in webpack.config:
module: {
rules: [
{ test: /.md$/, use: [{loader: "ts-loader", options: {logLevel: 'WARN', transpileOnly: true}}, "otherLoader"]},
{ test: /.ts$/, use: [{loader: "ts-loader", options: {logLevel: 'INFO', transpileOnly: false}}, "otherLoader"]}
]
}
Actual Behaviour
Since 7.0.0 this no longer works. successLoader in index.ts no longer accepts the options as a parameter so the loaderOptions will always be the options specified the first time ts_loader is invoked.
Steps to Reproduce the Problem
Create a webpack config which needs different options for different invocations of ts-loader
This could be fixed by adding a line to getTypeScriptInstance in instances.js:
function getTypeScriptInstance(loaderOptions, loader) {
if (instances.hasOwnProperty(loaderOptions.instance)) {
const instance = instances[loaderOptions.instance];
instance.loaderOptions = loaderOptions; // << Add this line
The text was updated successfully, but these errors were encountered: