Skip to content

Incorrect instance hash for different compiler options #1316

Closed
@timocov

Description

@timocov

Let's say you have 2 packages, and one of them you want to build with target=es5, another one with target=es6. If you set up ts-loader options to override compiler options (in loader options, not in tsconfig) it wont work properly.

There is a test https://github.com/TypeStrong/ts-loader/tree/main/test/execution-tests/loaderOptions for similar situation, but it doesn't cover this case. Let's say instead of overriding the only getCustomTransformers option you want to override something in compilerOptions. In this case this code will return [object Object] for both different objects (different ref and a value itself) which causes the issue (also this code doesn't cover a case when a value is false, thus if a value is falsy but enabled by default it will also failed).

Not too sure about the fix here. I see different approaches to solve it:

  1. Use JSON.stringify for non-functions and value.toString() otherwise
  2. Allow to provide a instanceKey or something like that so people can declare their own cache key and refer to them in different places

Maybe you have thoughts how to solve it in better way. Let me know you what do you think. I'm ready to make a fix for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions