Мой компонент:
Код: Выделить всё
import Button from '@mui/material/Button';
export default function Foo() {
return(
Contained
);
}
Код: Выделить всё
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
define: {
"process.env.NODE_ENV": JSON.stringify("production")
},
build: {
lib: {
entry: "src/Index.tsx",
name: "mycomponent",
formats: ["es"]
},
rollupOptions: {
external: ["react", "react-dom", "@mui/material", "@emotion/react", "@emotion/styled"],
}
}
})
При импорте с помощью:
Код: Выделить всё
const url = "http://127.0.0.1:8080/mycomponent"; //same url with curl
const Lazycomponent = lazy(() =>
import(/* @vite-ignore */ url).catch((err: unknown) => {
console.log(err);
}),
Код: Выделить всё
(new TypeError("Wrong module specifier", ""))
%s
%s
Я не знаю, почему у меня возникает эта проблема.
Я делаю что-то не так во время сборки/импорта?
Подробнее здесь: https://stackoverflow.com/questions/797 ... react-lazy
Мобильная версия