Skip to content

No longer possible to use different loader options for different files #1102

@appzuka

Description

@appzuka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions