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

enableForkedTypeScriptTypesChecking stops validating the .ts file types #1207

Open
erikas-tranauskas opened this issue May 12, 2023 · 2 comments

Comments

@erikas-tranauskas
Copy link

erikas-tranauskas commented May 12, 2023

I have a long running build times and I am trying to find a way to fix it. One of the solutions could be enabling the enableForkedTypeScriptTypesChecking. After enabling this setting it requires to install the fork-ts-checker-webpack-plugin@^6.0.0
and it cuts the build time almost in half, but the problem is that with this option enabled, the build doesn't validate the .ts files at all. I can remove all the types from the variables in .ts files and it still compiles successfully.

Any way to configure this to run smoothly?

My webpack.config.js:

const Encore = require('@symfony/webpack-encore');
const dotenvFlow = require('dotenv-flow');

if (!Encore.isRuntimeEnvironmentConfigured()) {
  Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'local');
}

Encore.setOutputPath('public/build/')
  .setPublicPath('/build')
  .addEntry('main', './assets/js/main.ts')
  .copyFiles({
    from: './assets/img',
    to: 'images/[path][name].[hash:8].[ext]',
  })
  .splitEntryChunks()
  .enableSingleRuntimeChunk()
  .cleanupOutputBeforeBuild()
  .enableBuildNotifications()
  .enableSourceMaps(!Encore.isProduction())
  .enableForkedTypeScriptTypesChecking()
  .enableVersioning(Encore.isProduction())
  .configureBabelPresetEnv((config) => {
    config.useBuiltIns = 'usage';
    config.corejs = 3;
  })
  .enableSassLoader()
  .enableTypeScriptLoader()
  .enableVueLoader()
  .configureDefinePlugin((options) => {
    const env = dotenvFlow.config({ silent: true });

    if (env.error) {
      throw env.error;
    }

    options['process.env'].PMP_API_BASE_URI = JSON.stringify(env.parsed.PMP_API_BASE_URI);
  });

Encore.addLoader({
  test: /\.ya?ml$/,
  loader: 'yaml-loader',
  type: 'json',
  options: { asJSON: true },
});

module.exports = Encore.getWebpackConfig();
@stof
Copy link
Member

stof commented May 12, 2023

If you read the documentation of fork-ts-checker-webpack-plugin, it explicitly say that you will need to run type checking separately from your webpack build when using this plugin (disabling type checking is a big part of what makes it faster)

@erikas-tranauskas
Copy link
Author

erikas-tranauskas commented May 12, 2023

I believe it should start this separate process by adding a plugin to webpack config.

.addPlugin(new ForkTsCheckerWebpackPlugin({ async: true }))
doesn't do much. Any idea how to start it?

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

No branches or pull requests

2 participants