From 103826d307b6ea572a0cb15ba38021fd95bea459 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 23 Aug 2022 15:50:54 +0800 Subject: [PATCH] chore: recover conflicts --- packages/vite/src/node/plugins/html.ts | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 780eb19175f97f..f4fe5bfee4089a 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -814,6 +814,51 @@ export type IndexHtmlTransform = transform: IndexHtmlTransformHook } +export function preImportMapHook( + config: ResolvedConfig +): IndexHtmlTransformHook { + return (html, ctx) => { + const importMapIndex = html.match(importMapRE)?.index + if (importMapIndex === undefined) return + + const moduleScriptIndex = html.match(moduleScriptRE)?.index + if (moduleScriptIndex === undefined) return + + if (moduleScriptIndex < importMapIndex) { + const relativeHtml = normalizePath( + path.relative(config.root, ctx.filename) + ) + config.logger.warnOnce( + colors.yellow( + colors.bold( + `(!)