From 9b135eadcf6ff5cd0947548e83f775bf7c0a1623 Mon Sep 17 00:00:00 2001 From: pshu Date: Mon, 3 Jun 2024 15:25:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?test:=20=E2=9C=85=20dynamic=20import=20in?= =?UTF-8?q?=20esbuild=20skipped=20on-resolvel=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preset-umi/fixtures/prepare-build/normal/bar/bar.less | 4 ++++ packages/preset-umi/fixtures/prepare-build/normal/bar/bar.tsx | 4 ++++ .../fixtures/prepare-build/normal/context/context.ts | 4 ++++ .../fixtures/prepare-build/normal/context/know.ext.txt | 0 .../preset-umi/fixtures/prepare-build/normal/context/qux.less | 0 .../preset-umi/fixtures/prepare-build/normal/context/qux.ts | 1 + .../preset-umi/fixtures/prepare-build/normal/context/some.css | 0 packages/preset-umi/fixtures/prepare-build/normal/index.ts | 2 ++ 8 files changed, 15 insertions(+) create mode 100644 packages/preset-umi/fixtures/prepare-build/normal/bar/bar.less create mode 100644 packages/preset-umi/fixtures/prepare-build/normal/context/context.ts create mode 100644 packages/preset-umi/fixtures/prepare-build/normal/context/know.ext.txt create mode 100644 packages/preset-umi/fixtures/prepare-build/normal/context/qux.less create mode 100644 packages/preset-umi/fixtures/prepare-build/normal/context/qux.ts create mode 100644 packages/preset-umi/fixtures/prepare-build/normal/context/some.css diff --git a/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.less b/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.less new file mode 100644 index 000000000000..2652a7fc4902 --- /dev/null +++ b/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.less @@ -0,0 +1,4 @@ + +.bar{ + color:red; +} diff --git a/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.tsx b/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.tsx index 9f17386851f7..325c75902c2c 100644 --- a/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.tsx +++ b/packages/preset-umi/fixtures/prepare-build/normal/bar/bar.tsx @@ -1 +1,5 @@ export const bar = 'bar'; +// @ts-ignore +import styles from "./bar.less" + +export {styles} diff --git a/packages/preset-umi/fixtures/prepare-build/normal/context/context.ts b/packages/preset-umi/fixtures/prepare-build/normal/context/context.ts new file mode 100644 index 000000000000..9e34e1de632b --- /dev/null +++ b/packages/preset-umi/fixtures/prepare-build/normal/context/context.ts @@ -0,0 +1,4 @@ +export async function load(x: string) { + + return import(`./${x}`) +} diff --git a/packages/preset-umi/fixtures/prepare-build/normal/context/know.ext.txt b/packages/preset-umi/fixtures/prepare-build/normal/context/know.ext.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/preset-umi/fixtures/prepare-build/normal/context/qux.less b/packages/preset-umi/fixtures/prepare-build/normal/context/qux.less new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/preset-umi/fixtures/prepare-build/normal/context/qux.ts b/packages/preset-umi/fixtures/prepare-build/normal/context/qux.ts new file mode 100644 index 000000000000..575abd99e24d --- /dev/null +++ b/packages/preset-umi/fixtures/prepare-build/normal/context/qux.ts @@ -0,0 +1 @@ +export const qux = {} diff --git a/packages/preset-umi/fixtures/prepare-build/normal/context/some.css b/packages/preset-umi/fixtures/prepare-build/normal/context/some.css new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/packages/preset-umi/fixtures/prepare-build/normal/index.ts b/packages/preset-umi/fixtures/prepare-build/normal/index.ts index 644b4c9e62fd..6ca25d050b56 100644 --- a/packages/preset-umi/fixtures/prepare-build/normal/index.ts +++ b/packages/preset-umi/fixtures/prepare-build/normal/index.ts @@ -9,5 +9,7 @@ import './a.html'; // relative imports import { bar } from './bar/bar'; import { foo } from './foo'; +import { load } from './context/context' console.log(foo); console.log(bar); +console.log(load) From c5efc64d6e863cd4ae19ab7b60de5780d590e5f3 Mon Sep 17 00:00:00 2001 From: pshu Date: Mon, 3 Jun 2024 15:26:20 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20add=20umi=20know=20ex?= =?UTF-8?q?t=20loader=20for=20dynamic=20import=20skipped=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/preset-umi/src/features/prepare/build.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/preset-umi/src/features/prepare/build.ts b/packages/preset-umi/src/features/prepare/build.ts index 9bc136e3f885..a984558a1b07 100644 --- a/packages/preset-umi/src/features/prepare/build.ts +++ b/packages/preset-umi/src/features/prepare/build.ts @@ -35,6 +35,9 @@ export async function build(opts: { '.jsx': 'tsx', '.ts': 'ts', '.tsx': 'tsx', + '.less': 'empty', + '.scss': 'empty', + '.sass': 'empty', }, // do I need this? // incremental: true, From 09d5d61eaf5330c79edd33383309d76dd435b7ac Mon Sep 17 00:00:00 2001 From: pshu Date: Mon, 3 Jun 2024 15:50:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20long=20list=20of?= =?UTF-8?q?=20empty=20loader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preset-umi/src/features/prepare/build.ts | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/preset-umi/src/features/prepare/build.ts b/packages/preset-umi/src/features/prepare/build.ts index a984558a1b07..966b1f912f4e 100644 --- a/packages/preset-umi/src/features/prepare/build.ts +++ b/packages/preset-umi/src/features/prepare/build.ts @@ -31,13 +31,11 @@ export async function build(opts: { loader: { // use tsx loader for js/jsx/ts/tsx files // since only ts support decorator + ...possibleExtUsingEmptyLoader, '.js': 'tsx', '.jsx': 'tsx', '.ts': 'ts', '.tsx': 'tsx', - '.less': 'empty', - '.scss': 'empty', - '.sass': 'empty', }, // do I need this? // incremental: true, @@ -80,3 +78,34 @@ export async function build(opts: { return [result, undefined]; } } + +const possibleExtUsingEmptyLoader = { + '.aac': 'empty', + '.css': 'empty', + '.less': 'empty', + '.sass': 'empty', + '.scss': 'empty', + '.eot': 'empty', + '.flac': 'empty', + '.gif': 'empty', + '.htm': 'empty', + '.html': 'empty', + '.ico': 'empty', + '.icon': 'empty', + '.jpeg': 'empty', + '.jpg': 'empty', + '.empty': 'empty', + '.mdx': 'empty', + '.mp3': 'empty', + '.mp4': 'empty', + '.ogg': 'empty', + '.otf': 'empty', + '.png': 'empty', + '.svg': 'empty', + '.ttf': 'empty', + '.wav': 'empty', + '.webm': 'empty', + '.webp': 'empty', + '.woff': 'empty', + '.woff2': 'empty', +} as const;