Skip to content

running vite build in a deno project, glob package is included in build #20262

Closed as not planned
@j4w8n

Description

@j4w8n

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??

  1. npx xk create repro
  2. Choose "deno" for runtime
  3. Accept the default "Yes, with Typescript"
  4. cd repro
  5. deno add -D npm:vite npm:@xinkjs/xink npm:@xinkjs/adapter-deno
  6. deno task build
  7. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions