mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix: allow use of nuxt3 in non-wsl windows environment (#308)
This commit is contained in:
parent
4521580fc3
commit
0a3041cdf9
@ -38,6 +38,7 @@
|
||||
"lerna": "^4.0.0",
|
||||
"object-hash": "^2.2.0",
|
||||
"typescript": "^4.3.5",
|
||||
"unbuild": "^0.3.1"
|
||||
"unbuild": "^0.3.1",
|
||||
"upath": "^2.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { resolve } = require('path')
|
||||
const { resolve } = require('upath')
|
||||
|
||||
module.exports = {
|
||||
appDir: resolve(__dirname, 'dist')
|
||||
|
@ -23,6 +23,7 @@
|
||||
"@vueuse/head": "^0.6.0",
|
||||
"hookable": "^4.4.1",
|
||||
"ohmyfetch": "^0.2.0",
|
||||
"upath": "^2.0.1",
|
||||
"vue": "^3.1.4",
|
||||
"vue-router": "^4.0.10",
|
||||
"vuex5": "^0.5.0-testing.3"
|
||||
|
@ -33,6 +33,7 @@
|
||||
"listhen": "^0.2.4",
|
||||
"mri": "^1.1.6",
|
||||
"unbuild": "^0.3.1",
|
||||
"upath": "^2.0.1",
|
||||
"v8-compile-cache": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import { requireModule } from '../utils/cjs'
|
||||
|
||||
export async function invoke (args) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import chokidar from 'chokidar'
|
||||
import debounce from 'debounce-promise'
|
||||
import { createServer, createLoadingHandler } from '../utils/server'
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { normalize } from 'upath'
|
||||
|
||||
export function resolveModule (id, paths?) {
|
||||
return require.resolve(id, {
|
||||
return normalize(require.resolve(id, {
|
||||
paths: [].concat(
|
||||
// @ts-ignore
|
||||
global.__NUXT_PREPATHS__,
|
||||
@ -8,7 +10,7 @@ export function resolveModule (id, paths?) {
|
||||
// @ts-ignore
|
||||
global.__NUXT_PATHS__
|
||||
).filter(Boolean)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
export function requireModule (id, paths?) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { resolve } from 'path'
|
||||
import { existsSync, promises as fsp } from 'fs'
|
||||
import { resolve } from 'upath'
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
export interface LoadDotEnvOptions {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { resolve } from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import { resolve } from 'upath'
|
||||
import defu from 'defu'
|
||||
import { applyDefaults } from 'untyped'
|
||||
import * as rc from 'rc9'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve, join } from 'path'
|
||||
import { resolve, join } from 'upath'
|
||||
import { existsSync, readdirSync } from 'fs'
|
||||
import defu from 'defu'
|
||||
import { isRelative, joinURL, hasProtocol } from 'ufo'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { join, resolve } from 'path'
|
||||
import { join, resolve } from 'upath'
|
||||
import env from 'std-env'
|
||||
import createRequire from 'create-require'
|
||||
import { pascalCase } from 'scule'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import { joinURL } from 'ufo'
|
||||
|
||||
export default {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import path, { basename, parse } from 'path'
|
||||
import fs from 'fs'
|
||||
import path, { basename, parse } from 'upath'
|
||||
import hash from 'hash-sum'
|
||||
import consola from 'consola'
|
||||
import { useNuxt } from '../nuxt'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { join } from 'path'
|
||||
import { join, normalize } from 'upath'
|
||||
import jiti from 'jiti'
|
||||
|
||||
// TODO: use create-require for jest environment
|
||||
@ -81,7 +81,7 @@ export function requireModulePkg (id: string, opts: RequireModuleOptions = {}) {
|
||||
|
||||
/** Resolve the path of a module. */
|
||||
export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
|
||||
return _require.resolve(id, {
|
||||
return normalize(_require.resolve(id, {
|
||||
paths: [].concat(
|
||||
// @ts-ignore
|
||||
global.__NUXT_PREPATHS__,
|
||||
@ -90,7 +90,7 @@ export function resolveModule (id: string, opts: ResolveModuleOptions = {}) {
|
||||
// @ts-ignore
|
||||
global.__NUXT_PATHS__
|
||||
).filter(Boolean)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
/** Try to resolve the path of a module, but don't emit an error if it can't be found. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { dirname, join, relative, resolve } from 'upath'
|
||||
import { dirname, join, normalize, relative, resolve } from 'upath'
|
||||
import { InputOptions, OutputOptions } from 'rollup'
|
||||
import defu from 'defu'
|
||||
import { terser } from 'rollup-plugin-terser'
|
||||
@ -198,8 +198,8 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
|
||||
rollupConfig.plugins.push(alias({
|
||||
entries: {
|
||||
'#nitro': nitroContext._internal.runtimeDir,
|
||||
'#nitro-renderer': require.resolve(resolve(nitroContext._internal.runtimeDir, 'app', renderer)),
|
||||
'#config': require.resolve(resolve(nitroContext._internal.runtimeDir, 'app/config')),
|
||||
'#nitro-renderer': normalize(require.resolve(resolve(nitroContext._internal.runtimeDir, 'app', renderer))),
|
||||
'#config': normalize(require.resolve(resolve(nitroContext._internal.runtimeDir, 'app/config'))),
|
||||
'#nitro-vue-renderer': vue2ServerRenderer,
|
||||
'#build': nitroContext._nuxt.buildDir,
|
||||
'~': nitroContext._nuxt.srcDir,
|
||||
|
@ -1,4 +1,5 @@
|
||||
import consola from 'consola'
|
||||
import { normalize } from 'upath'
|
||||
|
||||
const internalRegex = /^\.|\?|\.[mc]?js$|.ts$|.json$/
|
||||
|
||||
@ -9,7 +10,7 @@ export function autoMock () {
|
||||
if (src && !internalRegex.test(src)) {
|
||||
consola.warn('Auto mock external ', src)
|
||||
return {
|
||||
id: require.resolve('unenv/runtime/mock/proxy')
|
||||
id: normalize(require.resolve('unenv/runtime/mock/proxy'))
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Based on https://github.com/egoist/rollup-plugin-esbuild (MIT)
|
||||
|
||||
import { extname, relative } from 'path'
|
||||
import { extname, relative } from 'upath'
|
||||
import { Plugin, PluginContext } from 'rollup'
|
||||
import { Loader, TransformResult, transform } from 'esbuild'
|
||||
import { createFilter, FilterPattern } from '@rollup/pluginutils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve, dirname } from 'upath'
|
||||
import { resolve, dirname, normalize } from 'upath'
|
||||
import { copyFile, mkdirp } from 'fs-extra'
|
||||
import { nodeFileTrace, NodeFileTraceOptions } from '@vercel/nft'
|
||||
import type { Plugin } from 'rollup'
|
||||
@ -23,6 +23,11 @@ export function externals (opts: NodeExternalsOptions): Plugin {
|
||||
return null
|
||||
}
|
||||
|
||||
// Normalize path on windows
|
||||
if (process.platform === 'win32') {
|
||||
id = id.replace(/\\/g, '/')
|
||||
}
|
||||
|
||||
// Normalize from node_modules
|
||||
const _id = id.split('node_modules/').pop()
|
||||
|
||||
@ -42,7 +47,7 @@ export function externals (opts: NodeExternalsOptions): Plugin {
|
||||
// Try to resolve for nft
|
||||
if (opts.trace !== false) {
|
||||
let _resolvedId = _id
|
||||
try { _resolvedId = require.resolve(_resolvedId, { paths: opts.moduleDirectories }) } catch (_err) {}
|
||||
try { _resolvedId = normalize(require.resolve(_resolvedId, { paths: opts.moduleDirectories })) } catch (_err) { }
|
||||
resolvedExternals.add(_resolvedId)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Based on https://github.com/rollup/plugins/blob/master/packages/virtual/src/index.ts
|
||||
import * as path from 'path'
|
||||
import * as path from 'upath'
|
||||
|
||||
import { Plugin } from 'rollup'
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { normalize } from 'upath'
|
||||
import { wpfs, getNitroContext, createDevServer, resolveMiddleware, build, prepare, generate } from '@nuxt/nitro'
|
||||
import type { Nuxt } from '@nuxt/kit'
|
||||
|
||||
@ -22,7 +23,7 @@ export function initNitro (nuxt: Nuxt) {
|
||||
|
||||
// Add nitro client plugin (to inject $fetch helper)
|
||||
nuxt.hook('app:resolve', (app) => {
|
||||
app.plugins.push({ src: require.resolve('@nuxt/nitro/dist/runtime/app/nitro.client.mjs') })
|
||||
app.plugins.push({ src: normalize(require.resolve('@nuxt/nitro/dist/runtime/app/nitro.client.mjs')) })
|
||||
})
|
||||
|
||||
// Expose process.env.NITRO_PRESET
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { normalize } from 'upath'
|
||||
import Hookable from 'hookable'
|
||||
import { loadNuxtConfig, LoadNuxtOptions, Nuxt, NuxtOptions, nuxtCtx, installModule, ModuleContainer } from '@nuxt/kit'
|
||||
import { initNitro } from './nitro'
|
||||
@ -52,9 +53,9 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
|
||||
const { appDir } = await import('@nuxt/app/meta')
|
||||
options.appDir = appDir
|
||||
options._majorVersion = 3
|
||||
options.alias.vue = require.resolve('vue/dist/vue.esm-bundler.js')
|
||||
options.buildModules.push(require.resolve('@nuxt/pages/module'))
|
||||
options.buildModules.push(require.resolve('@nuxt/component-discovery/module'))
|
||||
options.alias.vue = normalize(require.resolve('vue/dist/vue.esm-bundler.js'))
|
||||
options.buildModules.push(normalize(require.resolve('@nuxt/pages/module')))
|
||||
options.buildModules.push(normalize(require.resolve('@nuxt/component-discovery/module')))
|
||||
|
||||
const nuxt = createNuxt(options)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { basename, extname } from 'path'
|
||||
import { basename, extname } from 'upath'
|
||||
import hash from 'hash-sum'
|
||||
import { camelCase } from 'scule'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import * as vite from 'vite'
|
||||
import vitePlugin from '@vitejs/plugin-vue'
|
||||
import { cacheDirPlugin } from './plugins/cache-dir'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import * as vite from 'vite'
|
||||
import vuePlugin from '@vitejs/plugin-vue'
|
||||
import { mkdirp, writeFile } from 'fs-extra'
|
||||
|
@ -35,6 +35,7 @@
|
||||
"style-resources-loader": "^1.4.1",
|
||||
"time-fix-plugin": "^2.0.7",
|
||||
"ufo": "^0.7.7",
|
||||
"upath": "^2.0.1",
|
||||
"url-loader": "^4.1.1",
|
||||
"vue": "3.1.4",
|
||||
"vue-loader": "^16.3.0",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import querystring from 'querystring'
|
||||
import path from 'upath'
|
||||
import webpack from 'webpack'
|
||||
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { normalize } from 'upath'
|
||||
import { getQuery } from 'ufo'
|
||||
|
||||
export default class NuxtSetupTransformerPlugin {
|
||||
@ -10,7 +11,7 @@ export default class NuxtSetupTransformerPlugin {
|
||||
enforce: 'post',
|
||||
use: [{
|
||||
ident: 'NuxtSetupTransformerPlugin',
|
||||
loader: require.resolve('@nuxt/webpack-builder/dist/nuxt-setup-loader')
|
||||
loader: normalize(require.resolve('@nuxt/webpack-builder/dist/nuxt-setup-loader'))
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/client.js
|
||||
*/
|
||||
|
||||
import { dirname } from 'path'
|
||||
import { dirname } from 'upath'
|
||||
import hash from 'hash-sum'
|
||||
import { uniq } from 'lodash'
|
||||
import { writeFile, mkdirp } from 'fs-extra'
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { normalize } from 'upath'
|
||||
import TerserWebpackPlugin from 'terser-webpack-plugin'
|
||||
import { reservedVueTags } from '../utils/reserved-tags'
|
||||
import { WebpackConfigContext } from '../utils/config'
|
||||
@ -6,7 +7,7 @@ export function babel (ctx: WebpackConfigContext) {
|
||||
const { config, options } = ctx
|
||||
|
||||
const babelLoader = {
|
||||
loader: require.resolve('babel-loader'),
|
||||
loader: normalize(require.resolve('babel-loader')),
|
||||
options: getBabelOptions(ctx)
|
||||
}
|
||||
|
||||
@ -66,7 +67,7 @@ function getBabelOptions (ctx: WebpackConfigContext) {
|
||||
babelOptions.plugins = babelOptions.plugins(ctx)
|
||||
}
|
||||
|
||||
const defaultPreset = [require.resolve('../../babel-preset-app'), {}]
|
||||
const defaultPreset = [normalize(require.resolve('../../babel-preset-app')), {}]
|
||||
|
||||
if (typeof babelOptions.presets === 'function') {
|
||||
babelOptions.presets = babelOptions.presets(ctx, defaultPreset)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve, normalize } from 'path'
|
||||
import { resolve, normalize } from 'upath'
|
||||
import TimeFixPlugin from 'time-fix-plugin'
|
||||
import WebpackBar from 'webpackbar'
|
||||
import consola from 'consola'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import path from 'path'
|
||||
import path from 'upath'
|
||||
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
||||
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'
|
||||
import { fileName, WebpackConfigContext, applyPresets } from '../utils/config'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5'
|
||||
import { DefinePlugin } from 'webpack'
|
||||
import NuxtSetupTransformerPlugin from '../plugins/transform-setup'
|
||||
|
@ -49,8 +49,8 @@ function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath
|
||||
}
|
||||
|
||||
function isPackageHoisted (packageName) {
|
||||
const path = require('path')
|
||||
const installedPath = require.resolve(packageName)
|
||||
const path = require('upath')
|
||||
const installedPath = path.normalize(require.resolve(packageName))
|
||||
const relativePath = path.resolve(__dirname, '..', 'node_modules', packageName)
|
||||
return installedPath !== relativePath
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import path from 'path'
|
||||
import path from 'upath'
|
||||
import pify from 'pify'
|
||||
import { Volume, createFsFromVolume } from 'memfs'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// @ts-nocheck
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import path from 'upath'
|
||||
import consola from 'consola'
|
||||
import { defaults, merge, cloneDeep } from 'lodash'
|
||||
import createResolver from 'postcss-import-resolver'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import type { IncomingMessage, ServerResponse } from 'http'
|
||||
import path from 'upath'
|
||||
import pify from 'pify'
|
||||
import webpack from 'webpack'
|
||||
import Glob from 'glob'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { execSync } from 'child_process'
|
||||
import { resolve } from 'upath'
|
||||
import globby from 'globby'
|
||||
|
||||
async function loadPackage (dir: string) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import { readFile } from 'fs-extra'
|
||||
import { JSDOM } from 'jsdom'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import { testNitroBuild, setupTest, testNitroBehavior } from './_utils'
|
||||
|
||||
describe('nitro:preset:lambda', () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import { testNitroBuild, startServer, setupTest, testNitroBehavior } from './_utils'
|
||||
|
||||
describe('nitro:preset:node', () => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'upath'
|
||||
import { testNitroBuild, setupTest, startServer, testNitroBehavior } from './_utils'
|
||||
|
||||
describe('nitro:preset:vercel', () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { resolve, dirname } from 'path'
|
||||
import { existsSync, readFileSync, writeFileSync, rmSync, mkdirSync } from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import { resolve, dirname } from 'upath'
|
||||
import defu from 'defu'
|
||||
import hash from 'object-hash'
|
||||
import type { LoadNuxtOptions, NuxtConfig } from '@nuxt/kit'
|
||||
|
@ -1660,6 +1660,7 @@ __metadata:
|
||||
hookable: ^4.4.1
|
||||
ohmyfetch: ^0.2.0
|
||||
unbuild: ^0.3.1
|
||||
upath: ^2.0.1
|
||||
vue: ^3.1.4
|
||||
vue-router: ^4.0.10
|
||||
vuex5: ^0.5.0-testing.3
|
||||
@ -1865,6 +1866,7 @@ __metadata:
|
||||
time-fix-plugin: ^2.0.7
|
||||
ufo: ^0.7.7
|
||||
unbuild: ^0.3.1
|
||||
upath: ^2.0.1
|
||||
url-loader: ^4.1.1
|
||||
vue: 3.1.4
|
||||
vue-loader: ^16.3.0
|
||||
@ -9981,6 +9983,7 @@ __metadata:
|
||||
listhen: ^0.2.4
|
||||
mri: ^1.1.6
|
||||
unbuild: ^0.3.1
|
||||
upath: ^2.0.1
|
||||
v8-compile-cache: ^2.3.0
|
||||
dependenciesMeta:
|
||||
fsevents:
|
||||
@ -10011,6 +10014,7 @@ __metadata:
|
||||
object-hash: ^2.2.0
|
||||
typescript: ^4.3.5
|
||||
unbuild: ^0.3.1
|
||||
upath: ^2.0.1
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user