alloc / alloc/vite-dts

doesn't work with ESM packages

Offen
#9 0 Kommentare 26 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
87
Forks
12
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

i have a package which uses ES modules, with `"type": "module",` in my `package.json`. if i remove that line, the build process completes successfully¹. however, if i keep it, it seems like the es module is not recognised because i get this error:

```
failed to load config from /foo/vite.config.js
error during build:
/foo/node_modules/vite-dts/dist/esm/plugin.js:1
import loadJSON from 'load-json-file';
^^^^^^

SyntaxError: Cannot use import statement outside a module

```

not sure if this is an issue with the plugin, or something wrong with my setup. here's my `vite.config.js`:

```
// @ts-check
import { defineConfig } from "vite";
import dts from "vite-dts";
import react from "@vitejs/plugin-react";

export default defineConfig({
build: {
lib: {
entry: "src/index.ts",
// fileName: (format) => `index.${format}.js`,
formats: ["es", "cjs"],
// name: "index.js",
},
rollupOptions: {
// externalize deps that shouldn't be bundled
// into your library
external: ["react", "react-dom"],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
react: "React",
},
// Since we publish our ./src folder, there's no point
// in bloating sourcemaps with another copy of it.
sourcemapExcludeSources: true,
},
},
sourcemap: true,
target: "esnext",
minify: false,
},
plugins: [dts(), react()],
});

```

¹ the process completes successfully, but the type definition files are not actually generated, i suspect it's related to #5.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.