Type Error Importer
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rollup, typescript, vite
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu với ví dụ vite.config.ts và bản tái hiện trên StackBlitz, tập trung vào nodePolyfills({ crypto: true }) trong build.rollupOptions.plugins. Tái hiện lỗi không tương thích của TypeScript và kiểm tra các kiểu hook Rollup của plugin. Được xem là hoàn tất khi cấu hình kiểm tra kiểu thành công mà không có lỗi resolveId đã báo cáo, đồng thời vẫn giữ tùy chọn crypto.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When I try to use nodePolyfills({ crypto: true }) as rollup option, i get following type error:
Type '{ name: string; resolveId(importee: string, importer: string): { id: any; moduleSideEffects: boolean; } | null; load(id: string): string | undefined; transform(code: string, id: string): any; }' is not assignable to type 'InputPluginOption'.
Type '{ name: string; resolveId(importee: string, importer: string): { id: any; moduleSideEffects: boolean; } | null; load(id: string): string | undefined; transform(code: string, id: string): any; }' is not assignable to type 'Plugin'.
Types of property 'resolveId' are incompatible.
Type '(importee: string, importer: string) => { id: any; moduleSideEffects: boolean; } | null' is not assignable to type 'ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { assertions: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>, {}> | undefined'.
Type '(importee: string, importer: string) => { id: any; moduleSideEffects: boolean; } | null' is not assignable to type '(this: PluginContext, source: string, importer: string | undefined, options: { assertions: Record<string, string>; custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>'.
Types of parameters 'importer' and 'importer' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
28 plugins: [nodePolyfills()],
~~~~~~~~~~~~~~~
This is my vite.config.ts:
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
import nodePolyfills from 'rollup-plugin-node-polyfills';
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 3000,
},
plugins: [react()],
resolve: {
alias: {
stream: 'rollup-plugin-node-polyfills/polyfills/stream',
events: 'rollup-plugin-node-polyfills/polyfills/events',
assert: 'assert',
crypto: 'crypto-browserify',
util: 'util',
'near-api-js': 'near-api-js/dist/near-api-js.js',
},
},
define: {
'process.env': process.env ?? {},
},
build: {
target: 'esnext',
rollupOptions: {
plugins: [nodePolyfills({ crypto: true })],
},
},
optimizeDeps: {
esbuildOptions: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
plugins: [NodeGlobalsPolyfillPlugin({ buffer: true }) as any],
},
},
});
Replicated the issue here: https://stackblitz.com/edit/vitejs-vite-uqkmtp?file=vite.config.ts
Does anybody have an idea how to solve this?
- Ngôn ngữ chính
- JavaScript
- Star
- 142
- Fork
- 64
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ionic-team/rollup-plugin-node-polyfills
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ionic-team/rollup-plugin-node-polyfills#62 · 2 bình luận · 6 reaction ·
-
Feature Request: http2 polyfillĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
ionic-team/rollup-plugin-node-polyfills#56 · 11 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
-
node:pathĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
ionic-team/rollup-plugin-node-polyfills#51 · 2 reaction ·
-
<GIT>Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Tất cả issue của ionic-team/rollup-plugin-node-polyfills
Issue tương tự
-
建议增加URL参数构建的工具Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
uoftblueprint/canada-basketball#67 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
打开群聊的设置同时打开侧边栏会出现侧边只出现一半Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
Fei2411/DeepSeek-Bot#456 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
área:app área:produto sem-fase tipo:decisão
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Varanda-org/varanda#91 ·
-
0️⃣ phase/new
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày