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: Use correct stage for adding assets during compilation #1286

Merged

Conversation

JonWallsten
Copy link
Contributor

No description provided.

@JonWallsten
Copy link
Contributor Author

@johnnyreilly: I extracted the fix from my previous webpack 5 branch and added on top of the v5. Seems to work fine!

compilation.hooks.processAssets.tap(
{
name: 'ts-loader',
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
Copy link
Member

Choose a reason for hiding this comment

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

What's the significance of the specified stage @JonWallsten?

Copy link
Member

Choose a reason for hiding this comment

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

"add additional assets to the compilation." I guess?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just the preferred way of doing it in Webpack 5. @alexander-akait metioned it in the beginning of the big PR. It shouldn't affect anything at all. It's just more future proof.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, it is right usage, we can implement cache here in future

@johnnyreilly
Copy link
Member

Cool - do you want to update the CHANGELOG.md and package.json ?

@JonWallsten
Copy link
Contributor Author

Cool - do you want to update the CHANGELOG.md and package.json ?

Done!

@johnnyreilly johnnyreilly merged commit 5e08d5d into TypeStrong:main Apr 20, 2021
@johnnyreilly
Copy link
Member

johnnyreilly commented Apr 20, 2021

Thanks!

https://github.com/TypeStrong/ts-loader/releases/tag/v9.0.1

@alexander-akait
Copy link
Contributor

@JonWallsten We can avoid using loader-utils https://github.com/TypeStrong/ts-loader/blob/main/src/index.ts#L2, it will be deprecated in near future:
https://github.com/TypeStrong/ts-loader/blob/main/src/index.ts#L177:

// No need fallback on `{}`, when not option it will be `{`}
const options = this.getOptions(schema); // schema is optional 

https://github.com/TypeStrong/ts-loader/blob/main/src/index.ts#L649, just change on:

loaderContext.remainingRequest

Because webpack v5 is minimum supported version, no breaking changes here, just less code and less deps

@JonWallsten JonWallsten deleted the add-correct-compilation-hook branch April 20, 2021 13:16
@johnnyreilly
Copy link
Member

Hey @alexander-akait

Are you saying that

  const loaderOptions =
    loaderUtils.getOptions<LoaderOptions>(loaderContext) ||
    ({} as LoaderOptions);

can become

const loaderOptions = this.getOptions(); // schema is optional 

?

@alexander-akait
Copy link
Contributor

Yes

@JonWallsten
Copy link
Contributor Author

I can do a PR if you'd like @johnnyreilly!

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

3 participants