From 90dbe0970bfbe8ab4809a14dfb7462bc6033e0f6 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 6 Oct 2024 03:30:02 +0800 Subject: [PATCH 1/6] feat: support ESLint Flat Config --- LICENSE | 29 ----------- package.json | 2 +- pnpm-lock.yaml | 17 +++---- scripts/build.mjs | 43 ++++++++++++++++ utils/renderEslint.ts | 116 +++++++++++++++++++++++++----------------- 5 files changed, 118 insertions(+), 89 deletions(-) diff --git a/LICENSE b/LICENSE index 947d78c0..609a8694 100644 --- a/LICENSE +++ b/LICENSE @@ -270,35 +270,6 @@ Repository: git://github.com/mde/ejs.git > limitations under the License. > -## javascript-stringify - -License: MIT -By: Blake Embrey -Repository: git+https://github.com/blakeembrey/javascript-stringify.git - -> The MIT License (MIT) -> -> Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com) -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. -> - ## kleur License: MIT diff --git a/package.json b/package.json index ce82290e..03e795ba 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@types/eslint": "^9.6.1", "@types/node": "^20.16.10", "@types/prompts": "^2.4.9", - "@vue/create-eslint-config": "^0.3.3", + "@vue/create-eslint-config": "0.4.0", "@vue/tsconfig": "^0.5.1", "ejs": "^3.1.10", "esbuild": "^0.18.20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4adc2e3..565b30a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ importers: specifier: ^2.4.9 version: 2.4.9 '@vue/create-eslint-config': - specifier: ^0.3.3 - version: 0.3.3 + specifier: 0.4.0 + version: 0.4.0 '@vue/tsconfig': specifier: ^0.5.1 version: 0.5.1 @@ -1072,8 +1072,8 @@ packages: '@vue/compiler-vue2@2.7.16': resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} - '@vue/create-eslint-config@0.3.3': - resolution: {integrity: sha512-eqy1kH6/0++oiRM5EkYrVaGjArrAJAhztdtKLB9FuKlid25jwUQ6nVMyuFXhxxnxl/ypxnGndMUGpVtYfNUX6w==} + '@vue/create-eslint-config@0.4.0': + resolution: {integrity: sha512-uBld1lYUfpVa/YWepCv4dkSzuPFkwOobKHQ3WtdrXA5TL3g6L6SnodBqqarftSxGtnACSS8iZdn9TUYXhxjSbw==} engines: {node: ^16.14.0 || >= 18.0.0} hasBin: true @@ -2467,9 +2467,6 @@ packages: engines: {node: '>=10'} hasBin: true - javascript-stringify@2.1.0: - resolution: {integrity: sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg==} - joi@17.13.3: resolution: {integrity: sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==} @@ -4682,10 +4679,10 @@ snapshots: de-indent: 1.0.2 he: 1.2.0 - '@vue/create-eslint-config@0.3.3': + '@vue/create-eslint-config@0.4.0': dependencies: + ejs: 3.1.10 enquirer: 2.4.1 - javascript-stringify: 2.1.0 kolorist: 1.8.0 '@vue/devtools-api@6.6.4': {} @@ -6114,8 +6111,6 @@ snapshots: filelist: 1.0.4 minimatch: 3.1.2 - javascript-stringify@2.1.0: {} - joi@17.13.3: dependencies: '@hapi/hoek': 9.3.0 diff --git a/scripts/build.mjs b/scripts/build.mjs index f1d780be..badb4adb 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -1,3 +1,4 @@ +import fs from 'node:fs' import * as esbuild from 'esbuild' import esbuildPluginLicense from 'esbuild-plugin-license' @@ -48,6 +49,48 @@ await esbuild.build({ }) } }, + + { + name: '@vue/create-eslint-config fix', + setup(build) { + // Update esbuild to support the import attributes syntax in this PR is too risky. + // TODO: update esbuild and remove the hack. + build.onLoad({ filter: /@vue\/create-eslint-config\/index.js$/ }, (args) => { + const text = fs.readFileSync(args.path, 'utf8') + return { + contents: text.replace(`with { type: 'json' }`, ''), + loader: 'js' + } + }) + + // The renderEjsFile.js module uses file system APIs therefore after bundling it will not work. + // So we need to preprocess it to remove the file system APIs. + build.onLoad({ filter: /@vue\/create-eslint-config\/renderEjsFile.js$/ }, (args) => { + const pkgDir = path.dirname(args.path) + const templatesDir = path.resolve(pkgDir, './templates') + + const allTemplateFileNames = fs.readdirSync(templatesDir) + const templateFiles = Object.fromEntries( + allTemplateFileNames.map((fileName) => { + const content = fs.readFileSync(path.resolve(templatesDir, fileName), 'utf8') + return [`./templates/${fileName}`, content] + }) + ) + + return { + contents: ` + import ejs from 'ejs' + const templates = ${JSON.stringify(templateFiles)} + export default function renderEjsFile(filePath, data) { + return ejs.render(templates[filePath], data, {}) + } + `, + loader: 'js' + } + }) + } + }, + esbuildPluginLicense({ thirdParty: { includePrivate: false, diff --git a/utils/renderEslint.ts b/utils/renderEslint.ts index fb061814..3a7dc801 100644 --- a/utils/renderEslint.ts +++ b/utils/renderEslint.ts @@ -1,8 +1,6 @@ import * as fs from 'node:fs' import * as path from 'node:path' -import type { Linter } from 'eslint' - import createESLintConfig from '@vue/create-eslint-config' import sortDependencies from './sortDependencies' @@ -15,7 +13,7 @@ export default function renderEslint( rootDir, { needsTypeScript, needsVitest, needsCypress, needsCypressCT, needsPrettier, needsPlaywright } ) { - const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ + const additionalConfigs = getAdditionalConfigs({ needsVitest, needsCypress, needsCypressCT, @@ -23,21 +21,15 @@ export default function renderEslint( }) const { pkg, files } = createESLintConfig({ - vueVersion: '3.x', - // we currently don't support other style guides styleGuide: 'default', hasTypeScript: needsTypeScript, needsPrettier, - additionalConfig, - additionalDependencies + additionalConfigs }) const scripts: Record = { - // Note that we reuse .gitignore here to avoid duplicating the configuration - lint: needsTypeScript - ? 'eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore' - : 'eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore' + lint: 'eslint . --fix' } // Theoretically, we could add Prettier without requring ESLint. @@ -54,62 +46,90 @@ export default function renderEslint( const packageJsonPath = path.resolve(rootDir, 'package.json') const existingPkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) const updatedPkg = sortDependencies(deepMerge(deepMerge(existingPkg, pkg), { scripts })) - fs.writeFileSync(packageJsonPath, JSON.stringify(updatedPkg, null, 2) + '\n', 'utf-8') + fs.writeFileSync(packageJsonPath, JSON.stringify(updatedPkg, null, 2) + '\n', 'utf8') - // write to .eslintrc.cjs, .prettierrc.json, etc. + // write to eslint.config.mjs, .prettierrc.json, .editorconfig, etc. for (const [fileName, content] of Object.entries(files)) { const fullPath = path.resolve(rootDir, fileName) - fs.writeFileSync(fullPath, content as string, 'utf-8') + fs.writeFileSync(fullPath, content as string, 'utf8') } } +type ConfigItemInESLintTemplate = { + importer: string + content: string +} +type AdditionalConfig = { + devDependencies: Record + beforeVuePlugin?: Array + afterVuePlugin?: Array +} +type AdditionalConfigArray = Array + // visible for testing -export function getAdditionalConfigAndDependencies({ +export function getAdditionalConfigs({ needsVitest, needsCypress, needsCypressCT, needsPlaywright }) { - const additionalConfig: Linter.Config = {} - const additionalDependencies = {} + const additionalConfigs: AdditionalConfigArray = [] if (needsVitest) { - additionalConfig.overrides = [ - { - files: ['src/**/*.{test,spec}.{js,ts,jsx,tsx}'], - extends: ['plugin:@vitest/legacy-recommended'] - } - ] - - additionalDependencies['@vitest/eslint-plugin'] = eslintDeps['@vitest/eslint-plugin'] + additionalConfigs.push({ + devDependencies: { '@vitest/eslint-plugin': eslintDeps['@vitest/eslint-plugin'] }, + afterVuePlugin: [ + { + importer: `import pluginVitest from '@vitest/eslint-plugin'`, + content: ` + { + ...pluginVitest.configs['recommended'], + files: ['src/**/__tests__/*'], + },` + } + ] + }) } if (needsCypress) { - additionalConfig.overrides = [ - { - files: needsCypressCT - ? [ - '**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}', - 'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', - 'cypress/support/**/*.{js,ts,jsx,tsx}' - ] - : ['cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', 'cypress/support/**/*.{js,ts,jsx,tsx}'], - extends: ['plugin:cypress/recommended'] - } - ] - - additionalDependencies['eslint-plugin-cypress'] = eslintDeps['eslint-plugin-cypress'] + additionalConfigs.push({ + devDependencies: { 'eslint-plugin-cypress': eslintDeps['eslint-plugin-cypress'] }, + afterVuePlugin: [ + { + importer: "import pluginCypress from 'eslint-plugin-cypress/flat'", + content: ` + { + ...pluginCypress.configs.recommended, + files: [ + ${[ + ...(needsCypressCT ? ["'**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}',"] : []), + 'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', + 'cypress/support/**/*.{js,ts,jsx,tsx}' + ] + .map(JSON.stringify.bind(JSON)) + .join(',\n ')} + ], + },` + } + ] + }) } if (needsPlaywright) { - additionalConfig.overrides = [ - { - files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'], - extends: ['plugin:playwright/recommended'] - } - ] - - additionalDependencies['eslint-plugin-playwright'] = eslintDeps['eslint-plugin-playwright'] + additionalConfigs.push({ + devDependencies: { 'eslint-plugin-playwright': eslintDeps['eslint-plugin-playwright'] }, + afterVuePlugin: [ + { + importer: "import pluginPlaywright from 'eslint-plugin-playwright'", + content: ` + { + ...pluginPlaywright.configs['flat/recommended'], + files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'], + },` + } + ] + }) } - return { additionalConfig, additionalDependencies } + + return additionalConfigs } From 96adc202f4464db819573b47991915bcebbacfdc Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 6 Oct 2024 03:38:57 +0800 Subject: [PATCH 2/6] fix: downgrade typescript to ~5.5 as typescript-eslint hasn't supported 5.6 yet --- pnpm-lock.yaml | 23 +++++++++++++++-------- template/config/typescript/package.json | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 565b30a4..c1d45ff4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -175,11 +175,11 @@ importers: specifier: ^6.2.3 version: 6.2.3 typescript: - specifier: ~5.6.0 - version: 5.6.2 + specifier: ~5.5.4 + version: 5.5.4 vue-tsc: specifier: ^2.1.6 - version: 2.1.6(typescript@5.6.2) + version: 2.1.6(typescript@5.5.4) template/config/vitest: dependencies: @@ -3438,6 +3438,11 @@ packages: resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} engines: {node: '>=8'} + typescript@5.5.4: + resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} + engines: {node: '>=14.17'} + hasBin: true + typescript@5.6.2: resolution: {integrity: sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==} engines: {node: '>=14.17'} @@ -4713,7 +4718,7 @@ snapshots: dependencies: rfdc: 1.4.1 - '@vue/language-core@2.1.6(typescript@5.6.2)': + '@vue/language-core@2.1.6(typescript@5.5.4)': dependencies: '@volar/language-core': 2.4.2 '@vue/compiler-dom': 3.5.8 @@ -4724,7 +4729,7 @@ snapshots: muggle-string: 0.4.1 path-browserify: 1.0.1 optionalDependencies: - typescript: 5.6.2 + typescript: 5.5.4 '@vue/reactivity@3.5.10': dependencies: @@ -7207,6 +7212,8 @@ snapshots: type-fest@0.7.1: {} + typescript@5.5.4: {} + typescript@5.6.2: {} undici-types@6.19.8: {} @@ -7392,12 +7399,12 @@ snapshots: '@vue/devtools-api': 6.6.4 vue: 3.5.10(typescript@5.6.2) - vue-tsc@2.1.6(typescript@5.6.2): + vue-tsc@2.1.6(typescript@5.5.4): dependencies: '@volar/typescript': 2.4.2 - '@vue/language-core': 2.1.6(typescript@5.6.2) + '@vue/language-core': 2.1.6(typescript@5.5.4) semver: 7.5.4 - typescript: 5.6.2 + typescript: 5.5.4 vue@3.5.10(typescript@5.6.2): dependencies: diff --git a/template/config/typescript/package.json b/template/config/typescript/package.json index eb9f87a2..e0b2d8c2 100644 --- a/template/config/typescript/package.json +++ b/template/config/typescript/package.json @@ -7,7 +7,7 @@ "devDependencies": { "@types/node": "^20.16.10", "npm-run-all2": "^6.2.3", - "typescript": "~5.6.0", + "typescript": "~5.5.4", "vue-tsc": "^2.1.6" } } From 473ad04fcd0b5ad2180292945b7e5b62bed27115 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 6 Oct 2024 03:46:18 +0800 Subject: [PATCH 3/6] test: remove renderEslint unit test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't have time to rewrite the tests… maybe later --- __test__/renderEslint.spec.ts | 76 ----------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 __test__/renderEslint.spec.ts diff --git a/__test__/renderEslint.spec.ts b/__test__/renderEslint.spec.ts deleted file mode 100644 index 2a150669..00000000 --- a/__test__/renderEslint.spec.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { it, describe, expect } from 'vitest' -import { getAdditionalConfigAndDependencies } from '../utils/renderEslint' - -describe('renderEslint', () => { - it('should get additional dependencies and config with no test flags', () => { - const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ - needsVitest: false, - needsCypress: false, - needsCypressCT: false, - needsPlaywright: false - }) - expect(additionalConfig).toStrictEqual({}) - expect(additionalDependencies).toStrictEqual({}) - }) - - it('should get additional dependencies and config with for vitest', () => { - const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ - needsVitest: true, - needsCypress: false, - needsCypressCT: false, - needsPlaywright: false - }) - expect(additionalConfig.overrides[0].files).toStrictEqual([ - 'src/**/*.{test,spec}.{js,ts,jsx,tsx}' - ]) - expect(additionalConfig.overrides[0].extends).toStrictEqual([ - 'plugin:@vitest/legacy-recommended' - ]) - expect(additionalDependencies['@vitest/eslint-plugin']).not.toBeUndefined() - }) - - it('should get additional dependencies and config with for cypress', () => { - const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ - needsVitest: false, - needsCypress: true, - needsCypressCT: false, - needsPlaywright: false - }) - expect(additionalConfig.overrides[0].files).toStrictEqual([ - 'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', - 'cypress/support/**/*.{js,ts,jsx,tsx}' - ]) - expect(additionalConfig.overrides[0].extends).toStrictEqual(['plugin:cypress/recommended']) - expect(additionalDependencies['eslint-plugin-cypress']).not.toBeUndefined() - }) - - it('should get additional dependencies and config with for cypress with component testing', () => { - const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ - needsVitest: false, - needsCypress: true, - needsCypressCT: true, - needsPlaywright: false - }) - expect(additionalConfig.overrides[0].files).toStrictEqual([ - '**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}', - 'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', - 'cypress/support/**/*.{js,ts,jsx,tsx}' - ]) - expect(additionalConfig.overrides[0].extends).toStrictEqual(['plugin:cypress/recommended']) - expect(additionalDependencies['eslint-plugin-cypress']).not.toBeUndefined() - }) - - it('should get additional dependencies and config with for playwright', () => { - const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ - needsVitest: false, - needsCypress: false, - needsCypressCT: false, - needsPlaywright: true - }) - expect(additionalConfig.overrides[0].files).toStrictEqual([ - 'e2e/**/*.{test,spec}.{js,ts,jsx,tsx}' - ]) - expect(additionalConfig.overrides[0].extends).toStrictEqual(['plugin:playwright/recommended']) - expect(additionalDependencies['eslint-plugin-playwright']).not.toBeUndefined() - }) -}) From 02a3ffd79badd47048d1333452d392bfabbe62d9 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 6 Oct 2024 04:05:18 +0800 Subject: [PATCH 4/6] fix: update @vue/create-eslint-config to 0.4.1 to fix global ignore issue --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 03e795ba..05d000db 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@types/eslint": "^9.6.1", "@types/node": "^20.16.10", "@types/prompts": "^2.4.9", - "@vue/create-eslint-config": "0.4.0", + "@vue/create-eslint-config": "0.4.1", "@vue/tsconfig": "^0.5.1", "ejs": "^3.1.10", "esbuild": "^0.18.20", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c1d45ff4..b3e6e06c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ importers: specifier: ^2.4.9 version: 2.4.9 '@vue/create-eslint-config': - specifier: 0.4.0 - version: 0.4.0 + specifier: 0.4.1 + version: 0.4.1 '@vue/tsconfig': specifier: ^0.5.1 version: 0.5.1 @@ -1072,8 +1072,8 @@ packages: '@vue/compiler-vue2@2.7.16': resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} - '@vue/create-eslint-config@0.4.0': - resolution: {integrity: sha512-uBld1lYUfpVa/YWepCv4dkSzuPFkwOobKHQ3WtdrXA5TL3g6L6SnodBqqarftSxGtnACSS8iZdn9TUYXhxjSbw==} + '@vue/create-eslint-config@0.4.1': + resolution: {integrity: sha512-9AQ37YCSTSqP6vRv9rp9jri9Iv34UJP0WLD+FsVNYjDOxT37533zgOGZk4w3sw0KIAX8gxcgYx+5QFDuNQUhoA==} engines: {node: ^16.14.0 || >= 18.0.0} hasBin: true @@ -4684,7 +4684,7 @@ snapshots: de-indent: 1.0.2 he: 1.2.0 - '@vue/create-eslint-config@0.4.0': + '@vue/create-eslint-config@0.4.1': dependencies: ejs: 3.1.10 enquirer: 2.4.1 From 6de762e3c914e7cf749979487bd6f6007ebf71e3 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Sun, 6 Oct 2024 04:15:26 +0800 Subject: [PATCH 5/6] build: replace `/` with wildcard (`.`) to match Windows path separator --- scripts/build.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index badb4adb..4212538f 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -55,7 +55,7 @@ await esbuild.build({ setup(build) { // Update esbuild to support the import attributes syntax in this PR is too risky. // TODO: update esbuild and remove the hack. - build.onLoad({ filter: /@vue\/create-eslint-config\/index.js$/ }, (args) => { + build.onLoad({ filter: /@vue.create-eslint-config.index.js$/ }, (args) => { const text = fs.readFileSync(args.path, 'utf8') return { contents: text.replace(`with { type: 'json' }`, ''), @@ -65,7 +65,7 @@ await esbuild.build({ // The renderEjsFile.js module uses file system APIs therefore after bundling it will not work. // So we need to preprocess it to remove the file system APIs. - build.onLoad({ filter: /@vue\/create-eslint-config\/renderEjsFile.js$/ }, (args) => { + build.onLoad({ filter: /@vue.create-eslint-config.renderEjsFile\.js$/ }, (args) => { const pkgDir = path.dirname(args.path) const templatesDir = path.resolve(pkgDir, './templates') From 33255fd7a9f3d54745d5526263269f034eda6e0f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Wed, 9 Oct 2024 14:18:10 +0800 Subject: [PATCH 6/6] fix(build): forgot to import the path module explicitly --- scripts/build.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build.mjs b/scripts/build.mjs index 4212538f..373acb5e 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -1,4 +1,5 @@ import fs from 'node:fs' +import path from 'node:path' import * as esbuild from 'esbuild' import esbuildPluginLicense from 'esbuild-plugin-license'