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

enableBuild causes no files to be outputted #60

Closed
fgblomqvist opened this issue Jul 27, 2021 · 5 comments · Fixed by #61
Closed

enableBuild causes no files to be outputted #60

fgblomqvist opened this issue Jul 27, 2021 · 5 comments · Fixed by #61

Comments

@fgblomqvist
Copy link
Contributor

If we have enableBuild set to true (the default), no files get outputted when building the app. Dev mode still works fine, but doing vite build results in this being the last message in terminal:

✓ 5396 modules transformed.

As in, it seems to skip rendering the chunks? Setting enableBuild to false makes the build work again.

@fi3ework
Copy link
Owner

could you provide a minimal re-produce repo or show the Vite configuration? Maybe some checker failed silently? 🤔

@fgblomqvist
Copy link
Contributor Author

This is our vite config (with enableBuild set to false, when we set it to true or remove it the build stops working):

import reactRefresh from '@vitejs/plugin-react-refresh';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    target: 'es2018',
  },
  plugins: [
    reactRefresh(),
    tsconfigPaths(),
    svgr(),
    checker({
      enableBuild: false,
      eslint: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
        files: ['./src'],
      },
      typescript: true,
    }),
  ],
});

@fgblomqvist
Copy link
Contributor Author

Did some further testing and if I do e.g.

    checker({
      enableBuild: true,
    }),

(as in, nothing enabled)
The build just stops really fast. So yeah it seems like whenever vite-plugin-checker fails the whole build fails? But it all happens silently. If I turn off enableBuild things work.

@fgblomqvist
Copy link
Contributor Author

Actually I'm guessing that what's happening is that as soon as checker finishes, the build ends for some reason.

@fgblomqvist
Copy link
Contributor Author

Found the issue, it's here:
https://github.com/fi3ework/vite-plugin-checker/blob/main/packages/vite-plugin-checker/src/main.ts#L76-L81

That code could be more readable if you made the buildStart async and then just awaited:

const exitCodes = await Promise.all(checkers.map((checker) => spawnChecker(checker, userConfig, localEnv)))
const exitCode = exitCodes.find((code) => code !== 0) || 0;
process.exit(exitCode)

Now it's pretty clear that vite-plugin-checker kills the process as soon as it's done, no matter what. The last line above should be changed to:

if (exitCode !== 0) process.exit(exitCode);

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 a pull request may close this issue.

2 participants