alloc / alloc/vite-dts

doesn't work with ESM packages

Aberta
#9 0 comentários 26 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
87
Forks
12
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.