HorusGoul / vite-plugin-stylex

Vite Plugin for StyleX
MIT License
110 stars 11 forks source link

Laravel + React #32

Closed Engazan closed 6 months ago

Engazan commented 6 months ago

Hi, i rlly wanted to try stylex for my projects but i cant figure out whats wrong, so i think something is wrong with this plugin cuz when i switch out from vite it just works

my vite plugin config file

import {defineConfig} from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';
import styleX from "vite-plugin-stylex";

export default defineConfig({
    plugins: [
        laravel(['resources/js/index.tsx']),
        react(),
        styleX(),
    ],
});

my vite packages:

"devDependencies": {
        "@stylexjs/dev-runtime": "^0.4.1",
        "@stylexjs/eslint-plugin": "^0.4.1",
        "@vitejs/plugin-react": "^4.2.1",
        "laravel-vite-plugin": "^0.7.2",
        "vite": "^4.0.0",
        "vite-plugin-stylex": "^0.4.1"
    },

error:

error when starting dev server:
Error: Build failed with 1 error:
node_modules/esbuild/lib/main.js:1373:27: ERROR: [plugin: externalize-deps] "vite-plugin-stylex" resolved to an ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.
    ...

fixes like adding "type": "module" or renaming vite.config just brings another problems like stylex.inject is not a function also i found -> https://github.com/facebook/stylex/issues/47

is there any working solution ?, thanks

HorusGoul commented 6 months ago

See #29 for the stylex.inject stuff, will close this one since the other problem is related to ESM/CommonJS. This plugin is only available as an ESM module, so you need "type": "module" or using mts or mjs extension for the vite config file.