[WxtBuilder]: importEntrypoint is causing xxx not defined error.
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
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
- 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.
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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