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

Fix getOptionsHash when two options has different props but same values. #1170

Merged

Conversation

meowtec
Copy link
Contributor

@meowtec meowtec commented Aug 14, 2020

Fix the issue when I use both lang="tsx" and lang="ts" in vue single file components.
For lang="ts":

{
  appendTsSuffixTo: [/\.vue$/],
  transpileOnly: true,
}

For lang="tsx":

{
  appendTsxSuffixTo: [/\.vue$/],
  transpileOnly: true,
}

They get the same hash because getOptionsHash use only values for hashing.
So for tsx vue file, it reuses the loader options which is only for ts vue, which add .ts suffix not .tsx.
That can lead to wrong compilation result.

@meowtec meowtec changed the title Fix getOptionsHash when two options has different props but same values. [WIP]Fix getOptionsHash when two options has different props but same values. Aug 14, 2020
@meowtec
Copy link
Contributor Author

meowtec commented Aug 14, 2020

There is still something wrong, let me find it out.

@meowtec meowtec changed the title [WIP]Fix getOptionsHash when two options has different props but same values. Fix getOptionsHash when two options has different props but same values. Aug 22, 2020
@meowtec
Copy link
Contributor Author

meowtec commented Aug 22, 2020

The another issue is that I using thread-loader with ts-loader. It serializes the RegExp object to {}.

@johnnyreilly
Copy link
Member

For some reason the Travis build has failed...

@meowtec
Copy link
Contributor Author

meowtec commented Aug 23, 2020

Allow to use string in appendTsSuffixTo.

If ts-loader runs in child process, the RegExp object will be serialized and unserialized to {}, then the match result will always be True.

'/User/xxx/project'.match({})
// ["e", index: 2, input: "User", groups: undefined]

In this case we should use string instead of RegExp.

@johnnyreilly
Copy link
Member

Looks good - do you want to add an entry to the CHANGELOG.md and increment the package.json?

By the way, you might not need thread-loader:

https://blog.johnnyreilly.com/2018/12/you-might-not-need-thread-loader.html

@johnnyreilly johnnyreilly merged commit 0e64ceb into TypeStrong:master Aug 24, 2020
@johnnyreilly
Copy link
Member

Just published https://github.com/TypeStrong/ts-loader/releases/tag/v8.0.3 - thanks for your work! 🤗🌻

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.

2 participants