fix(auto-imports): windows issue with parsing query from path (#3700)

Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
pooya parsa 2022-03-16 14:41:37 +01:00 committed by GitHub
parent 452a7730e0
commit cb6a4e97c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 9 deletions

View File

@ -65,8 +65,7 @@ jobs:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
node: [14]
steps:
@ -93,8 +92,7 @@ jobs:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
node: [14]
steps:

View File

@ -1,4 +1,5 @@
import crypto from 'crypto'
import { pathToFileURL } from 'url'
import { createUnplugin } from 'unplugin'
import { parse } from 'acorn'
import MagicString from 'magic-string'
@ -22,7 +23,7 @@ export const KeyPlugin = createUnplugin(() => {
name: 'nuxt-legacy-capi-key-transform',
enforce: 'pre',
transformInclude (id) {
const { pathname, search } = parseURL(id)
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
const query = parseQuery(search)
if (id.includes('node_modules')) {

View File

@ -1,3 +1,4 @@
import { pathToFileURL } from 'url'
import { createUnplugin } from 'unplugin'
import { parseQuery, parseURL } from 'ufo'
import { Unimport } from 'unimport'
@ -8,7 +9,7 @@ export const TransformPlugin = createUnplugin(({ ctx, options }: {ctx: Unimport,
name: 'nuxt:auto-imports-transform',
enforce: 'post',
transformInclude (id) {
const { pathname, search } = parseURL(id)
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
const { type, macro } = parseQuery(search)
const exclude = options.transform?.exclude || [/[\\/]node_modules[\\/]/]

View File

@ -1,3 +1,4 @@
import { pathToFileURL } from 'url'
import { createUnplugin } from 'unplugin'
import { parseQuery, parseURL } from 'ufo'
import { Component } from '@nuxt/schema'
@ -12,7 +13,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => ({
name: 'nuxt:components-loader',
enforce: 'post',
transformInclude (id) {
const { pathname, search } = parseURL(id)
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
const query = parseQuery(search)
// we only transform render functions
// from `type=template` (in Webpack) and bare `.vue` file (in Vite)

View File

@ -1,3 +1,4 @@
import { pathToFileURL } from 'url'
import { createUnplugin } from 'unplugin'
import { parseQuery, parseURL, withQuery } from 'ufo'
import { findStaticImports, findExports } from 'mlly'
@ -14,12 +15,12 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
enforce: 'post',
transformInclude (id) {
if (!id || id.startsWith('\x00')) { return }
const { search, pathname } = parseURL(id)
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
return pathname.endsWith('.vue') || !!parseQuery(search).macro
},
transform (code, id) {
const s = new MagicString(code)
const { search } = parseURL(id)
const { search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
function result () {
if (s.hasChanged()) {