Repository navigation
Closed as not planned
Description
Describe the bug
// entrypoints/content.ts
const routes: Record<string, any> = import.meta.glob("../providers/*", {
eager: true,
})
const matches = Object.keys(routes).flatMap((k) => routes[k].default.paths)
export default defineContentScript({
matches,
async main() {
console.log("Hello content.")
},
})
// providers/A.ts
export default {
paths: ["*://*.example.com/*"],
}OUTPUT:
ERROR import_meta.glob is not a function 19:55:49
at C:/Users/Orlando/Desktop/test-wxt/entrypoints/content.ts:25:28
at evalModule (node_modules\.pnpm\[email protected]\node_modules\jiti\dist\jiti.js:1:256443)
at jiti (node_modules\.pnpm\[email protected]\node_modules\jiti\dist\jiti.js:1:254371)
at importEntrypointFile (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:2278:23)
at async getContentScriptEntrypoint (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:1528:35)
at async /C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:1308:18
at async Promise.all (index 1)
at async findEntrypoints (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:1294:23)
at async internalBuild (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3165:23)
at async buildAndOpenBrowser (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3494:28)
✖ Command failed after 936 ms 19:55:49
ERROR Failed to load entrypoint: entrypoints\content.ts 19:55:49
at importEntrypointFile (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:2290:13)
at async getContentScriptEntrypoint (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:1528:35)
at async /C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:1308:18
at async Promise.all (index 1)
at async findEntrypoints (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:1294:23)
at async internalBuild (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3165:23)
at async buildAndOpenBrowser (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3494:28)
at async Object.start (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3459:9) at async /C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3980:5
at async CAC.<anonymous> (/C:/Users/Orlando/Desktop/test-wxt/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/wxt/dist/cli.js:3911:22)
To Reproduce
- Create a new project
pnpm dlx wxt@latest init <project-name> - Add the 2 files listed in
Describe the bugsection - pnpm run dev
OR
test-wxt.zip
Steps to reproduce the bug using the reproduction:
- Install dependencies:
pnpm i - Start dev mode:
pnpm dev
Expected behavior
no error
Environment
System:
OS: Windows 10 10.0.19045
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 7.18 GB / 15.92 GB
Binaries:
Node: 21.5.0 - C:\Program Files\nodejs\node.EXE
npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.0.6 - ~\AppData\Roaming\npm\pnpm.CMD
Browsers:
Edge: Chromium (123.0.2420.97)
Internet Explorer: 11.0.19041.3636
Metadata
Metadata
Assignees
Labels
No labels
Activity
aklinker1 commentedon Apr 28, 2024
Duplicate/apart of #506, will be fixed after I get #585 finished.
Vite isn't used to load entrypoints during build when reading entrypoint options, like content script
matches, so you can't use Vite APIs, likeimport.meta.glob, outside themainfunction.aklinker1 commentedon May 3, 2024
I'm gonna close this issue, it will be fixed in #506, follow that one for updates.