wxt-dev / wxt-dev/wxt

[WxtBuilder]: importEntrypoint is causing xxx not defined error.

Open
#1,281 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

open-source-1
As entrypointLoader is going to be deparecated or has, by default vite-node to import entrypoints as of version 0.19.0

using await wxt.builder.importEntrypoint(entrypointPath) to import options is breaking.

Reproduction

add a file in modules sub-folder of the project
Add this below code

demo.ts

import { addEntrypoint, defineWxtModule } from 'wxt/modules';
import path, { resolve } from 'node:path';

export default defineWxtModule(async (wxt) => {
  const entrypointPath = resolve(
    path.join('src', 'entrypoints'),
    'unlisted.ts',
  );

  console.log({
    entrypointPath,
    dd: await wxt.builder.importEntrypoint(entrypointPath),
  });
  addEntrypoint(wxt, {
    type: 'unlisted-script',
    name: 'demo-module',
    inputPath: entrypointPath,
    outputDir: wxt.config.outDir,
    options: {},
  });
});

Add a unlisted.ts file inside entrypoints sub-folder of the project.

unlisted.ts

export default defineUnlistedScript(() => {
  console.log('injected');
});

Try running

pnpm build
Steps to reproduce

No response

System Info
System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 Intel(R) Core(TM) i3-10105 CPU @ 3.70GHz
    Memory: 827.90 MB / 7.84 GB
  Binaries:
    Node: 22.0.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.5 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.13.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.86)
    Internet Explorer: 11.0.22621.3527
Used Package Manager

pnpm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WxtBuilder importEntrypoint entry point and the entrypointLoader/vite-node behavior described in the issue. Reproduce the example using demo.ts and unlisted.ts, then run pnpm build and inspect the resulting “not defined” error. Done means importing the entrypoint options no longer fails in this reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript, vite
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.