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

feat: add zero-config support for fork-ts-checker-webpack-plugin #1451

Conversation

piotr-oles
Copy link
Contributor

Hi! 👋
I'm a maintainer of the fork-ts-checker-webpack-plugin.
Currently, we have to set transpileOnly: true to skip type-checking on the loader side.
With this change it's no longer the case - the loader will detect if there is a checker plugin in the configuration and set default transpileOnly: true if that's the case. I hope this will improve DX and make webpack config files cleaner and smarter :)

Before:

// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
  context: __dirname, // to automatically find tsconfig.json
  entry: './src/index.ts',
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader',
        options: {
          // disable type checker - we will use it in fork plugin
          transpileOnly: true
        }
      }
    ]
  },
  plugins: [new ForkTsCheckerWebpackPlugin()]
};

After:

// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
  context: __dirname, // to automatically find tsconfig.json
  entry: './src/index.ts',
  resolve: {
    extensions: [".ts", ".tsx", ".js"],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'ts-loader'
      }
    ]
  },
  plugins: [new ForkTsCheckerWebpackPlugin()]
};

I tested this manually, please let me know if you need some automatic tests for this.

@johnnyreilly
Copy link
Member

Hey @piotr-oles - I know who you are! 😅

I think this is a great improvement! Could we make an enhancement? With the current implementation, you can't explicitly control transpileOnly - it's always derived from whether the plugin is present.

If someone wants to run with transpileOnly and not use a checker, we'd still want to support that.

So passing transpileOnly: false should be possible in the absence of checker usage. Would you be up for making that change?

@johnnyreilly
Copy link
Member

Actually, I read that wrong - your PR already implements the behaviour I mentioned. Could you update the README.md to document new usage of fork-ts-checker-webpack-plugin, increment the version in the package.json and add an entry to the CHANGELOG.md please?

@piotr-oles
Copy link
Contributor Author

Sure, I will do that!

@piotr-oles piotr-oles force-pushed the feature/zero-config-fork-ts-checker-webpack-plugin branch from 6e2b2f4 to 35e65c7 Compare April 29, 2022 21:50
@piotr-oles
Copy link
Contributor Author

Done! ✅

Copy link
Member

@johnnyreilly johnnyreilly left a comment

Choose a reason for hiding this comment

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

Let's ship it!

@johnnyreilly johnnyreilly merged commit b943237 into TypeStrong:main Apr 30, 2022
@johnnyreilly
Copy link
Member

johnnyreilly commented Apr 30, 2022

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

2 participants