Skip to content

Commit

Permalink
fix: downgrade module-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 21, 2024
1 parent 3ae1f57 commit de79dc4
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 480 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@antfu/ni": "^0.21.12",
"@nuxt/devtools": "workspace:*",
"@nuxt/devtools-ui-kit": "workspace:*",
"@nuxt/module-builder": "^0.8.0",
"@nuxt/module-builder": "~0.6.0",
"@nuxt/schema": "^3.12.2",
"@types/markdown-it": "^14.1.1",
"@types/node": "^20.14.7",
Expand Down
29 changes: 29 additions & 0 deletions packages/devtools/build.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fileURLToPath } from 'node:url'
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
Expand All @@ -22,4 +23,32 @@ export default defineBuildConfig({
rollup: {
inlineDependencies: true,
},
hooks: {
// Patch @nuxt/module-builder@0.6.0 not adding .mjs extension for runtime files
// https://github.com/nuxt/module-builder/issues/261
'rollup:options': (_, options) => {
options.plugins ||= []
if (!Array.isArray(options.plugins))
options.plugins = [options.plugins]

const runtimeDir = fileURLToPath(new URL('./src/runtime', import.meta.url))
options.plugins.unshift({
name: 'unbuild:runtime-build:patch',
async resolveId(id, importter) {
if (!id.includes('runtime'))
return
const resolved = await this.resolve(id, importter, { skipSelf: true })
if (resolved?.id.startsWith(runtimeDir)) {
let id = resolved.id
if (!id.endsWith('.mjs'))
id += '.mjs'
return {
external: true,
id,
}
}
},
})
},
},
})
6 changes: 3 additions & 3 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
"@nuxt/devtools-kit": "workspace:*",
"@nuxt/devtools-wizard": "workspace:*",
"@nuxt/kit": "^3.12.2",
"@vue/devtools-applet": "7.1.3",
"@vue/devtools-core": "7.1.3",
"@vue/devtools-kit": "7.1.3",
"birpc": "^0.2.17",
"consola": "^3.2.3",
"cronstrue": "^2.50.0",
Expand Down Expand Up @@ -99,6 +96,9 @@
"@unocss/preset-uno": "^0.61.0",
"@unocss/runtime": "^0.61.0",
"@vitest/ui": "^1.6.0",
"@vue/devtools-applet": "7.1.3",
"@vue/devtools-core": "7.1.3",
"@vue/devtools-kit": "7.1.3",
"@vueuse/nuxt": "^10.11.0",
"esno": "^4.7.0",
"floating-vue": "5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/module-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@iconify-json/carbon": "^1.1.36",
"@nuxt/devtools": "workspace:*",
"@nuxt/devtools-ui-kit": "workspace:*",
"@nuxt/module-builder": "^0.8.0",
"@nuxt/module-builder": "~0.6.0",
"@nuxt/schema": "^3.12.2",
"@nuxt/test-utils": "^3.13.1",
"eslint": "^9.5.0",
Expand Down
Loading

0 comments on commit de79dc4

Please sign in to comment.