alloc / alloc/vite-dts

doesn't work with ESM packages

未关闭
#9 0 条评论 26 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
87
派生
12
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。