Running `dev:prepare` in the root of a module behaves differently than preparing in the playground
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- nuxt, typescript
- Domain
- build-system, tooling
Research direction
Start with the dev:prepare command and the @nuxt/module-builder prepare flow, then reproduce the failure using the linked nuxt-module-layers-repro project. Trace how the module setup function is first run and how nuxi prepare playground runs afterward. Done means preparing from the module root handles layer file discovery consistently with preparing in the playground.
Written by the indexing model from the issue text.
Description
@lewebsimple pointed out an edge case where, if a module checks for the existence of a certain file, running the dev:prepare script will fail when executed from the root of the module (via @nuxt/module-builder).
Reproduction
https://github.com/lewebsimple/nuxt-module-layers-repro
const rootDirs = getLayerDirectories().map(({ root }) => root)
let discoverMePath
for (const rootDir of rootDirs) {
if (existsSync(`${rootDir}/discover-me.txt`)) {
discoverMePath = `${rootDir}/discover-me.txt`
logger.info(`Found discover-me.txt in layer: ${rootDir}`)
break
}
}
if (!discoverMePath) {
throw new Error('Required file discover-me.txt not found in any layer directories.')
}
Steps to reproduce
- run
pnpm dev:preparein the root of the project - see that it fails
Additional context
This happens because the module's setup function runs initially without taking the playground directory into account, and only afterward does it run separately for the playground.
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
- Dominant language
- TypeScript
- Stars
- 276
- Forks
- 36
- Avg merge
- 4h 16m
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from nuxt/module-builder
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
nuxt/module-builder#720 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
nuxt/module-builder#801 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
nuxt/module-builder#764 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
nuxt/module-builder#754 ·
-
Conflict between folder structure in readme (src/runtime) and TypeScript config (src/module/runtime)Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
nuxt/module-builder#749 ·
All issues in nuxt/module-builder
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
keytrace logo svg?Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
HigherOrderCO/Bend#1294 ·
-
Price: 75 USD Priority: 2 (Medium) Time: <1 Hour
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day