Skip to content

Commit

Permalink
fix: temporarily disable the esbuild attribute in the vite plugin (#1789
Browse files Browse the repository at this point in the history
)

* fix: Temporarily disable the esbuild attribute in the vite plugin

* fix: add constant

* fix: add constant
  • Loading branch information
ErKeLost authored Sep 23, 2024
1 parent e17551a commit 4542c3d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 70 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-cows-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/core": patch
---

Temporarily disable the esbuild attribute in the vite plugin
2 changes: 1 addition & 1 deletion examples/vite-adapter-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@farmfe/plugin-sass": "workspace:^",
"@types/bcryptjs": "^2.4.5",
"@unocss/postcss": "^0.62.2",
"@vitejs/plugin-vue": "^4.6.2",
"@vitejs/plugin-vue": "5.1.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"postcss": "^8.4.32",
"postcss-pxtorem": "^6.0.0",
Expand Down
18 changes: 16 additions & 2 deletions packages/core/src/plugin/js/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const VITE_DEFAULT_ASSETS = [
export const VITE_DEFAULT_ASSETS: string[] = [
// images
'apng',
'png',
Expand Down Expand Up @@ -37,4 +37,18 @@ export const VITE_DEFAULT_ASSETS = [
'txt'
];
// the name of the virtual module internal the adapter
export const VITE_ADAPTER_VIRTUAL_MODULE = 'vite-adapter-virtual:';
export const VITE_ADAPTER_VIRTUAL_MODULE: string = 'vite-adapter-virtual:';

export const VITE_EXTERNAL_KEYS: string[] = ['esbuild'];

export const RESERVED_OBJECT_PROPERTIES: string[] = [
'then',
'length',
'constructor',
'prototype'
];

export const EXTERNAL_KEYS: string[] = [
...VITE_EXTERNAL_KEYS,
...RESERVED_OBJECT_PROPERTIES
];
6 changes: 2 additions & 4 deletions packages/core/src/plugin/js/farm-to-vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { UserConfig as ViteUserConfig } from 'vite';
import type { UserConfig } from '../../config/types.js';
import { Logger } from '../../index.js';
import merge from '../../utils/merge.js';
import { VITE_DEFAULT_ASSETS } from './constants.js';
import { EXTERNAL_KEYS, VITE_DEFAULT_ASSETS } from './constants.js';
import {
deleteUndefinedPropertyDeeply,
throwIncompatibleError
Expand Down Expand Up @@ -108,9 +108,7 @@ function getTargetField(
return target[key as unknown as keyof typeof target];
}

const internalKeys = ['then', 'length', 'constructor', 'prototype'];

if (internalKeys.includes(key)) {
if (EXTERNAL_KEYS.includes(key)) {
return (target as Record<string, any>)[key];
}

Expand Down
92 changes: 29 additions & 63 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4542c3d

Please sign in to comment.