Description
Describe the bug
I created a vite plugin, which only does SSR builds, but it is only for building APIs, so it's likely a bit of an oddity.
In a deno project, whenever I deno task build
(which runs vite build
), the final built index.js file includes the glob
package, which is imported in the vite plugin's main file.
Example import snippet from built file - I suspect all of which is from the 'glob' package. (additional "glob" content from the built file not shown).
/* build/index.js */
import { fileURLToPath } from 'node:url';
import { win32, posix } from 'node:path';
import { realpathSync as realpathSync$1, readlinkSync, readdirSync, readdir as readdir$1, lstatSync } from 'fs';
import * as actualFS from 'node:fs';
import { realpath, readlink, readdir, lstat } from 'node:fs/promises';
import { EventEmitter } from 'node:events';
import Stream from 'node:stream';
import { StringDecoder } from 'node:string_decoder';
I do not want/need the "glob" contents, but even if that's not feasible, a secondary issue here is that for some reason the 3rd import
does not prefix fs
with node:
- causing issues for deno.
Conversely, in a bun project, when running bun run build
(which also runs vite build
), the final built index.js file just includes import 'glob';
- which I believe is the more correct output, although I have no idea what I'm talking about.
Why is the built output for a deno project including all of the glob
package things? And even if that output is how Vite wants to handle this, is the lack of node:
prefix for the one import
line a vite bug?
Reproduction
https://xinkjs.com/start/quickstart/
Steps to reproduce
I don't know that I can use vite.new or npm create vite@latest
or npm create vite-extra@latest
, since this is regarding a vite plugin library I created??
npx xk create repro
- Choose "deno" for runtime
- Accept the default "Yes, with Typescript"
cd repro
deno add -D npm:vite npm:@xinkjs/xink npm:@xinkjs/adapter-deno
deno task build
- Observe contents of
build/index.js
System Info
Using Ubuntu on WSL
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz
Memory: 4.11 GB / 7.63 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.10.0 - /usr/bin/node
npm: 10.2.5 - /usr/bin/npm
pnpm: 9.4.0 - /mnt/c/Users/jcrev/AppData/Local/pnpm/pnpm
bun: 1.2.10 - ~/.bun/bin/bun
Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.