From 3c398bcfd2cfee3e994b810e84dcc5ce84b9d4fa Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Sun, 8 May 2022 12:59:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dvite=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=9C=A8win=E4=B8=8B=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fes-build-vite/src/common/getConfig.js | 3 +- packages/fes-compiler/src/service/getPaths.js | 19 ++-- packages/fes-plugin-locale/src/utils/index.js | 5 +- scripts/build.mjs | 2 +- yarn.lock | 88 +------------------ 5 files changed, 13 insertions(+), 104 deletions(-) diff --git a/packages/fes-build-vite/src/common/getConfig.js b/packages/fes-build-vite/src/common/getConfig.js index 4fd02a8e..2e753c2c 100644 --- a/packages/fes-build-vite/src/common/getConfig.js +++ b/packages/fes-build-vite/src/common/getConfig.js @@ -23,7 +23,8 @@ export function getInnerCommonConfig(api) { vueJsx(api.config.viteVueJsx || {}), createHtmlPlugin({ minify: true, - entry: join(api.paths.absTmpPath, 'fes.js'), + // 使用绝对地址在win下会提示没有权限 + entry: `src/${api.paths.tmpDir}/fes.js`, template: 'index.html', inject: { data: { diff --git a/packages/fes-compiler/src/service/getPaths.js b/packages/fes-compiler/src/service/getPaths.js index 76841195..d0e2bcb4 100644 --- a/packages/fes-compiler/src/service/getPaths.js +++ b/packages/fes-compiler/src/service/getPaths.js @@ -12,32 +12,25 @@ function isDirectoryAndExist(path) { } function normalizeWithWinPath(obj) { - return lodash.mapValues(obj, value => winPath(value)); + return lodash.mapValues(obj, (value) => winPath(value)); } -export default function getServicePaths({ - cwd, - config, - env -}) { +export default function getServicePaths({ cwd, config, env }) { let absSrcPath = cwd; if (isDirectoryAndExist(join(cwd, 'src'))) { absSrcPath = join(cwd, 'src'); } - const absPagesPath = config.singular - ? join(absSrcPath, 'page') - : join(absSrcPath, 'pages'); + const absPagesPath = config.singular ? join(absSrcPath, 'page') : join(absSrcPath, 'pages'); - const tmpDir = ['.fes', env !== 'development' && env] - .filter(Boolean) - .join('-'); + const tmpDir = ['.fes', env !== 'development' && env].filter(Boolean).join('-'); return normalizeWithWinPath({ + tmpDir, cwd, absNodeModulesPath: join(cwd, 'node_modules'), absOutputPath: join(cwd, config.outputPath || './dist'), absSrcPath, absPagesPath, - absTmpPath: join(absSrcPath, tmpDir) + absTmpPath: join(absSrcPath, tmpDir), }); } diff --git a/packages/fes-plugin-locale/src/utils/index.js b/packages/fes-plugin-locale/src/utils/index.js index 2c915173..9991de2b 100644 --- a/packages/fes-plugin-locale/src/utils/index.js +++ b/packages/fes-plugin-locale/src/utils/index.js @@ -1,4 +1,4 @@ -import { glob } from '@fesjs/utils'; +import { glob, winPath } from '@fesjs/utils'; import { join, basename } from 'path'; export function getLocales(cwd) { @@ -13,7 +13,8 @@ export function getLocales(cwd) { return { importName, locale, - path: join(cwd, fileName), + // import语法的路径,必须处理win + path: winPath(join(cwd, fileName)), }; }); diff --git a/scripts/build.mjs b/scripts/build.mjs index 7650883a..58c7e3ee 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -68,7 +68,7 @@ function getGlobalConfig() { async function getPkgConfig(config, pkgName) { const pkgConfigPath = path.join(getPkgPath(pkgName), CONFIG_FILE_NAME); if (fs.existsSync(pkgConfigPath)) { - const content = await import(pkgConfigPath); + const content = await import(process.platform === 'win32' ? `file://${pkgConfigPath}` : pkgConfigPath); return merge(config, content.default); } diff --git a/yarn.lock b/yarn.lock index 2f7a760e..867a26c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3427,24 +3427,6 @@ body-parser@1.19.2: raw-body "2.4.3" type-is "~1.6.18" -body-parser@^1.19.0: - version "1.20.0" - resolved "https://registry.npmmirror.com/body-parser/-/body-parser-1.20.0.tgz#3de69bd89011c11573d7bfee6a64f11b6bd27cc5" - integrity sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg== - dependencies: - bytes "3.1.2" - content-type "~1.0.4" - debug "2.6.9" - depd "2.0.0" - destroy "1.2.0" - http-errors "2.0.0" - iconv-lite "0.4.24" - on-finished "2.4.1" - qs "6.10.3" - raw-body "2.5.1" - type-is "~1.6.18" - unpipe "1.0.0" - bonjour-service@^1.0.11: version "1.0.11" resolved "https://registry.npmmirror.com/bonjour-service/-/bonjour-service-1.0.11.tgz#5418e5c1ac91c89a406f853a942e7892829c0d89" @@ -4124,25 +4106,12 @@ convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: dependencies: safe-buffer "~5.1.1" -cookie-parser@^1.4.5: - version "1.4.6" - resolved "https://registry.npmmirror.com/cookie-parser/-/cookie-parser-1.4.6.tgz#3ac3a7d35a7a03bbc7e365073a26074824214594" - integrity sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA== - dependencies: - cookie "0.4.1" - cookie-signature "1.0.6" - cookie-signature@1.0.6: version "1.0.6" resolved "https://registry.npmmirror.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== -cookie@0.4.1: - version "0.4.1" - resolved "https://registry.npmmirror.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1" - integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA== - -cookie@0.4.2, cookie@^0.4.2: +cookie@0.4.2: version "0.4.2" resolved "https://registry.npmmirror.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== @@ -4564,21 +4533,11 @@ delayed-stream@~1.0.0: resolved "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== -depd@2.0.0: - version "2.0.0" - resolved "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - depd@~1.1.2: version "1.1.2" resolved "https://registry.npmmirror.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== -destroy@1.2.0: - version "1.2.0" - resolved "https://registry.npmmirror.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" - integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== - destroy@~1.0.4: version "1.0.4" resolved "https://registry.npmmirror.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" @@ -6134,17 +6093,6 @@ http-errors@1.8.1: statuses ">= 1.5.0 < 2" toidentifier "1.0.1" -http-errors@2.0.0: - version "2.0.0" - resolved "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" - integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== - dependencies: - depd "2.0.0" - inherits "2.0.4" - setprototypeof "1.2.0" - statuses "2.0.1" - toidentifier "1.0.1" - http-errors@~1.6.2: version "1.6.3" resolved "https://registry.npmmirror.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" @@ -7752,11 +7700,6 @@ mime@1.6.0, mime@^1.4.1: resolved "https://registry.npmmirror.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== -mime@^3.0.0: - version "3.0.0" - resolved "https://registry.npmmirror.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" - integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== - mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.npmmirror.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" @@ -8105,13 +8048,6 @@ obuf@^1.0.0, obuf@^1.1.2: resolved "https://registry.npmmirror.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== -on-finished@2.4.1: - version "2.4.1" - resolved "https://registry.npmmirror.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" - integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== - dependencies: - ee-first "1.1.1" - on-finished@~2.3.0: version "2.3.0" resolved "https://registry.npmmirror.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -8924,13 +8860,6 @@ qiankun@^2.4.4: single-spa "^5.9.2" tslib "^1.10.0" -qs@6.10.3: - version "6.10.3" - resolved "https://registry.npmmirror.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e" - integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ== - dependencies: - side-channel "^1.0.4" - qs@6.9.7: version "6.9.7" resolved "https://registry.npmmirror.com/qs/-/qs-6.9.7.tgz#4610846871485e1e048f44ae3b94033f0e675afe" @@ -8973,16 +8902,6 @@ raw-body@2.4.3: iconv-lite "0.4.24" unpipe "1.0.0" -raw-body@2.5.1: - version "2.5.1" - resolved "https://registry.npmmirror.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857" - integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig== - dependencies: - bytes "3.1.2" - http-errors "2.0.0" - iconv-lite "0.4.24" - unpipe "1.0.0" - react-is@^17.0.1: version "17.0.2" resolved "https://registry.npmmirror.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" @@ -9832,11 +9751,6 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" -statuses@2.0.1: - version "2.0.1" - resolved "https://registry.npmmirror.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" - integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== - "statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.npmmirror.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"