FogelAI / babel-plugin-transform-barrels

A Babel plugin that transforms indirect imports through a barrel file (index.js) into direct imports.
15 stars 2 forks source link

Does this plugin work with Vite? #4

Open AXeL-dev opened 3 months ago

AXeL-dev commented 3 months ago

Hello, i'm using this plugin with vite & ts-jest, still when running my tests i get the following error:

image

I'm using the following babel config:

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react",
    "@babel/preset-typescript"
  ],
  "plugins": ["babel-plugin-transform-barrels"]
}

And the following jest config:

import { Config } from 'jest';

const config: Config = {
  testEnvironment: 'jsdom',
  testTimeout: 30000,
  transform: {
    '^.+\\.(t|j)sx?$': [
      'ts-jest',
      {
        tsconfig: 'tsconfig.test.json',
        babelConfig: true,
        useESM: true,
      },
    ],
  },
  setupFiles: ['<rootDir>/setup.jest.ts'],
  testPathIgnorePatterns: ['<rootDir>/node_modules/'],
  modulePathIgnorePatterns: ['<rootDir>/node_modules/'],
  testRegex: '(<rootDir>/src/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
 ...
};

export default config;

Is there anything missing in my config or maybe your plugin does only support webpack?

FogelAI commented 3 weeks ago

Hi @AXeL-dev I have released a new version of the plugin (v1.0.16) that adds support for Vite.

Please update your version and let me know if it resolves your issue.

Thanks