[go: nahoru, domu]

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

Adding @lingui/swc-plugin to react while using @vitejs/plugin-react-swc crashes the application. #65

Closed
harsimarriar96-dappquire opened this issue Jun 22, 2023 · 5 comments

Comments

@harsimarriar96-dappquire
Copy link
harsimarriar96-dappquire commented Jun 22, 2023

I am currently facing an issue here.

Here's my vitejs configuration

import { lingui } from '@lingui/vite-plugin';
import react from '@vitejs/plugin-react-swc';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, type PluginOption } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import { configDefaults } from 'vitest/config';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react({ plugins: [['@lingui/swc-plugin', {}]] }),
    lingui(),
    visualizer({
      brotliSize: true,
      emitFile: true,
      filename: 'bundle-size.html',
      gzipSize: true,
    }) as PluginOption,
    tsconfigPaths(),
  ],
  test: {
    ...configDefaults,
    environment: 'jsdom',
    exclude: ['**/node_modules/**', '**/dist/**'],
    include: ['**/*.test.{ts,tsx}'],
    name: 'jsdom',
    setupFiles: ['../setupTests.ts'],
  },
});

When adding plugins: [['@lingui/swc-plugin', {}]] in my configuration, it crashes the whole application.

It is randomly crashing at a component with unexpected token error because it's not compiling properly after adding this plugin.

Currently using these versions:
@lingui/swc-plugin 4.0.2

@timofei-iatsenko
Copy link
Collaborator

Please use code blocks for formatting. https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet

Also there are not enough info about your issue. How exactly it is crashed, with what error message. Also, you didn't provide what version of @swc/core and @lingui/swc-plugin you use.

Meanwhile, i'm pretty sure (95%) that you have versions misalignment. Please read compatibility section carefully and adjust your project accordingly.

@harsimarriar96-dappquire
Copy link
Author
harsimarriar96-dappquire commented Jun 22, 2023

@thekip

I have updated the description accordingly.

I am currently using @lingui/swc-plugin 4.0.2 and haven't installed @swc/core library since we're not importing that anywhere, is there something I am missing with @swc/core?

@timofei-iatsenko
Copy link
Collaborator

Please use syntax highlighting for code blocks.

@vitejs/plugin-react-swc has a dependency to @swc/core. So you have some undefined version of @swc/core installed (probably latest?). If you read compatibility section carefully, you may found that there are BREAKING changes in plugin support between minor version of @swc/core. So it's very important to have exact version of plugin to be compatible with exact version of @swc/core

@harsimarriar96-dappquire
Copy link
Author

@vitejs/plugin-react-swc has a depedency of @swc/core version 1.3.61. According to the compatibility document @lingui/swc-plugin version 4.0.2 should be supported, but I am still facing the same issue. Attaching a screenshot of the error after applying the plugin.

image

@thekip

@timofei-iatsenko
Copy link
Collaborator

@harsimarriar96-dappquire @vitejs/plugin-react-swc specify @swc/core with a caret (^), it means it will install latest possible version of the moment when you hit install.
So if you just checked theirs package.json and posted it here, it doesn't mean you're actually using this version.

Depending on your package manager, you need to use a different command to see what actual version of @swc/core Is installed in your project. You can also simply find this package in node_modules and check the version.

I'm pretty sure this issue caused by version incompatibility.

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