From a11afe19d3b14e43007b34730bfb715fdcd060e3 Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Thu, 22 Feb 2024 14:13:24 +0800 Subject: [PATCH 1/2] fix: slash runtime path --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index e493a9b..20dd0cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,10 @@ import { findFile } from "pkg-types"; export {} from "./types"; +function slash(path: string) { + return path.replace(/\\/g, "/"); +} + async function nitroModule(nitro: Nitro) { if (!nitro.options.dev) { return; // Production doesn't need this @@ -56,13 +60,13 @@ async function nitroModule(nitro: Nitro) { // Make sure runtime is transpiled nitro.options.externals.inline = nitro.options.externals.inline || []; nitro.options.externals.inline.push( - fileURLToPath(new URL("runtime/", import.meta.url)), + slash(fileURLToPath(new URL("runtime/", import.meta.url))), ); // Add plugin to inject bindings to dev server nitro.options.plugins = nitro.options.plugins || []; nitro.options.plugins.push( - fileURLToPath(new URL("runtime/plugin.dev", import.meta.url)), + slash(fileURLToPath(new URL("runtime/plugin.dev", import.meta.url))), ); } From 55b9e4a34e153feeb1aa131f86e95430459f8000 Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Thu, 22 Feb 2024 18:27:11 +0800 Subject: [PATCH 2/2] chore: use fileURLToPath from mlly --- package.json | 1 + pnpm-lock.yaml | 46 ++++++++++++++++++++++++++++++++++------------ src/index.ts | 10 +++------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 3610ef2..4fd74a4 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ }, "dependencies": { "consola": "^3.2.3", + "mlly": "^1.6.0", "pkg-types": "^1.0.3" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9e4fa6..e6b87e4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: consola: specifier: ^3.2.3 version: 3.2.3 + mlly: + specifier: ^1.6.0 + version: 1.6.0 pkg-types: specifier: ^1.0.3 version: 1.0.3 @@ -1374,7 +1377,7 @@ packages: h3: 1.10.0 knitwork: 1.0.0 magic-string: 0.30.5 - mlly: 1.5.0 + mlly: 1.6.0 ohash: 1.1.3 pathe: 1.1.2 perfect-debounce: 1.0.0 @@ -1451,6 +1454,7 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -1460,6 +1464,7 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -1469,6 +1474,7 @@ packages: engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] + libc: [musl] requiresBuild: true dev: true optional: true @@ -1478,6 +1484,7 @@ packages: engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -1487,6 +1494,7 @@ packages: engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] + libc: [musl] requiresBuild: true dev: true optional: true @@ -1840,6 +1848,7 @@ packages: resolution: {integrity: sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==} cpu: [arm64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -1848,6 +1857,7 @@ packages: resolution: {integrity: sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==} cpu: [arm64] os: [linux] + libc: [musl] requiresBuild: true dev: true optional: true @@ -1856,6 +1866,7 @@ packages: resolution: {integrity: sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==} cpu: [riscv64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -1864,6 +1875,7 @@ packages: resolution: {integrity: sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==} cpu: [x64] os: [linux] + libc: [glibc] requiresBuild: true dev: true optional: true @@ -1872,6 +1884,7 @@ packages: resolution: {integrity: sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==} cpu: [x64] os: [linux] + libc: [musl] requiresBuild: true dev: true optional: true @@ -2767,7 +2780,7 @@ packages: dotenv: 16.3.2 giget: 1.2.1 jiti: 1.21.0 - mlly: 1.5.0 + mlly: 1.6.0 ohash: 1.1.3 pathe: 1.1.2 perfect-debounce: 1.0.0 @@ -4061,7 +4074,7 @@ packages: resolution: {integrity: sha512-LyExtJWKxtgVzmgtEHyQtLFpw1KFhQphF9nTG8TpAIVkiI/xQ3FJh75tRFLYl4hkn7BNIIdLJInuDAavX35pMw==} dependencies: enhanced-resolve: 5.15.0 - mlly: 1.5.0 + mlly: 1.6.0 pathe: 1.1.2 ufo: 1.3.2 dev: true @@ -5128,7 +5141,7 @@ packages: h3: 1.10.0 http-shutdown: 1.2.2 jiti: 1.21.0 - mlly: 1.5.0 + mlly: 1.6.0 node-forge: 1.3.1 pathe: 1.1.2 std-env: 3.7.0 @@ -5146,7 +5159,7 @@ packages: resolution: {integrity: sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==} engines: {node: '>=14'} dependencies: - mlly: 1.5.0 + mlly: 1.6.0 pkg-types: 1.0.3 dev: true @@ -5487,7 +5500,7 @@ packages: fs-extra: 11.2.0 globby: 13.2.2 jiti: 1.21.0 - mlly: 1.5.0 + mlly: 1.6.0 mri: 1.2.0 pathe: 1.1.2 postcss: 8.4.33 @@ -5502,6 +5515,15 @@ packages: pathe: 1.1.2 pkg-types: 1.0.3 ufo: 1.3.2 + dev: true + + /mlly@1.6.0: + resolution: {integrity: sha512-YOvg9hfYQmnaB56Yb+KrJE2u0Yzz5zR+sLejEvF4fzwzV1Al6hkf2vyHTwqCRyv0hCi9rVCqVoXpyYevQIRwLQ==} + dependencies: + acorn: 8.11.3 + pathe: 1.1.2 + pkg-types: 1.0.3 + ufo: 1.3.2 /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} @@ -5609,7 +5631,7 @@ packages: listhen: 1.5.6 magic-string: 0.30.5 mime: 3.0.0 - mlly: 1.5.0 + mlly: 1.6.0 mri: 1.2.0 node-fetch-native: 1.6.1 ofetch: 1.3.3 @@ -5890,7 +5912,7 @@ packages: klona: 2.0.6 knitwork: 1.0.0 magic-string: 0.30.5 - mlly: 1.5.0 + mlly: 1.6.0 nitropack: 2.8.1 nuxi: 3.10.0 nypm: 0.3.4 @@ -6273,7 +6295,7 @@ packages: resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} dependencies: jsonc-parser: 3.2.0 - mlly: 1.5.0 + mlly: 1.6.0 pathe: 1.1.2 /pluralize@8.0.0: @@ -7700,7 +7722,7 @@ packages: jiti: 1.21.0 magic-string: 0.30.5 mkdist: 1.4.0(typescript@5.3.3) - mlly: 1.5.0 + mlly: 1.6.0 pathe: 1.1.2 pkg-types: 1.0.3 pretty-bytes: 6.1.1 @@ -7792,7 +7814,7 @@ packages: fast-glob: 3.3.2 local-pkg: 0.5.0 magic-string: 0.30.5 - mlly: 1.5.0 + mlly: 1.6.0 pathe: 1.1.2 pkg-types: 1.0.3 scule: 1.2.0 @@ -7837,7 +7859,7 @@ packages: fast-glob: 3.3.2 json5: 2.2.3 local-pkg: 0.4.3 - mlly: 1.5.0 + mlly: 1.6.0 pathe: 1.1.2 scule: 1.2.0 unplugin: 1.6.0 diff --git a/src/index.ts b/src/index.ts index 20dd0cb..fdea68a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ -import { fileURLToPath } from "node:url"; import { relative, resolve } from "node:path"; import { promises as fs } from "node:fs"; +import { fileURLToPath } from "mlly"; import type { Nitro } from "nitropack"; import type { Nuxt } from "nuxt/schema"; import consola from "consola"; @@ -9,10 +9,6 @@ import { findFile } from "pkg-types"; export {} from "./types"; -function slash(path: string) { - return path.replace(/\\/g, "/"); -} - async function nitroModule(nitro: Nitro) { if (!nitro.options.dev) { return; // Production doesn't need this @@ -60,13 +56,13 @@ async function nitroModule(nitro: Nitro) { // Make sure runtime is transpiled nitro.options.externals.inline = nitro.options.externals.inline || []; nitro.options.externals.inline.push( - slash(fileURLToPath(new URL("runtime/", import.meta.url))), + fileURLToPath(new URL("runtime/", import.meta.url)) ); // Add plugin to inject bindings to dev server nitro.options.plugins = nitro.options.plugins || []; nitro.options.plugins.push( - slash(fileURLToPath(new URL("runtime/plugin.dev", import.meta.url))), + fileURLToPath(new URL("runtime/plugin.dev", import.meta.url)) ); }