@weapp-vite/web 1.3.37 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -5
- package/dist/_virtual/_rolldown/runtime.mjs +19 -1
- package/dist/compiler/wxml/attributes.mjs +1 -1
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/compile.mjs +6 -3
- package/dist/compiler/wxml/compile.mjs.map +1 -1
- package/dist/compiler/wxml/interpolation.mjs +1 -2
- package/dist/compiler/wxml/interpolation.mjs.map +1 -1
- package/dist/compiler/wxml/navigation.mjs +5 -7
- package/dist/compiler/wxml/navigation.mjs.map +1 -1
- package/dist/compiler/wxml/parser.mjs +5 -5
- package/dist/compiler/wxml/parser.mjs.map +1 -1
- package/dist/compiler/wxml/renderer.mjs +16 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +8 -2
- package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
- package/dist/compiler/wxml/types.d.mts +12 -0
- package/dist/compiler/wxs.mjs +5 -5
- package/dist/compiler/wxs.mjs.map +1 -1
- package/dist/css/wxss.d.mts +1 -0
- package/dist/css/wxss.mjs +110 -9
- package/dist/css/wxss.mjs.map +1 -1
- package/dist/index.d.mts +24 -6
- package/dist/index.mjs +21 -4
- package/dist/plugin/assets.d.mts +7 -0
- package/dist/plugin/assets.mjs +122 -0
- package/dist/plugin/assets.mjs.map +1 -0
- package/dist/plugin/constants.mjs +10 -1
- package/dist/plugin/constants.mjs.map +1 -1
- package/dist/plugin/dependencyScan.mjs +41 -0
- package/dist/plugin/dependencyScan.mjs.map +1 -0
- package/dist/plugin/entry.mjs +55 -6
- package/dist/plugin/entry.mjs.map +1 -1
- package/dist/plugin/files.mjs +1 -1
- package/dist/plugin/files.mjs.map +1 -1
- package/dist/plugin/index.d.mts +37 -3
- package/dist/plugin/index.mjs +244 -73
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/layout.mjs +24 -0
- package/dist/plugin/layout.mjs.map +1 -0
- package/dist/plugin/path.mjs +6 -2
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +45 -33
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +211 -92
- package/dist/plugin/scan.mjs.map +1 -1
- package/dist/plugin/scanSfc.mjs +65 -0
- package/dist/plugin/scanSfc.mjs.map +1 -0
- package/dist/plugin/state.mjs +3 -2
- package/dist/plugin/state.mjs.map +1 -1
- package/dist/plugin/styleModule.mjs +52 -0
- package/dist/plugin/styleModule.mjs.map +1 -0
- package/dist/plugin/types.d.mts +37 -1
- package/dist/plugin/vueSfc.mjs +150 -0
- package/dist/plugin/vueSfc.mjs.map +1 -0
- package/dist/runtime/appShell/container.mjs +25 -0
- package/dist/runtime/appShell/container.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/index.mjs +192 -0
- package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/style.mjs +127 -0
- package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
- package/dist/runtime/button/helpers.mjs +1 -58
- package/dist/runtime/button/helpers.mjs.map +1 -1
- package/dist/runtime/button/index.d.mts +4 -5
- package/dist/runtime/button/index.mjs +6 -28
- package/dist/runtime/button/index.mjs.map +1 -1
- package/dist/runtime/button/style.mjs +53 -28
- package/dist/runtime/button/style.mjs.map +1 -1
- package/dist/runtime/component/behavior.mjs +26 -2
- package/dist/runtime/component/behavior.mjs.map +1 -1
- package/dist/runtime/component/element.mjs +107 -31
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/component/observers.mjs +36 -0
- package/dist/runtime/component/observers.mjs.map +1 -0
- package/dist/runtime/component/publicInstance.mjs +48 -0
- package/dist/runtime/component/publicInstance.mjs.map +1 -0
- package/dist/runtime/component/relations.mjs +36 -0
- package/dist/runtime/component/relations.mjs.map +1 -0
- package/dist/runtime/component/slots.mjs +24 -0
- package/dist/runtime/component/slots.mjs.map +1 -0
- package/dist/runtime/component/state.mjs +13 -3
- package/dist/runtime/component/state.mjs.map +1 -1
- package/dist/runtime/component/types.d.mts +29 -4
- package/dist/runtime/component/virtualHost.mjs +83 -0
- package/dist/runtime/component/virtualHost.mjs.map +1 -0
- package/dist/runtime/host/index.d.mts +13 -0
- package/dist/runtime/host/index.mjs +47 -0
- package/dist/runtime/host/index.mjs.map +1 -0
- package/dist/runtime/host/types.d.mts +28 -0
- package/dist/runtime/hostGlobals.d.mts +9 -0
- package/dist/runtime/hostGlobals.mjs +39 -0
- package/dist/runtime/hostGlobals.mjs.map +1 -0
- package/dist/runtime/index.d.mts +21 -3
- package/dist/runtime/index.mjs +26 -4
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/dom.mjs +3 -3
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/expression.mjs +9 -9
- package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/index.mjs +6 -6
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
- package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
- package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
- package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
- package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/form.d.mts +7 -0
- package/dist/runtime/nativeComponents/form.mjs +50 -0
- package/dist/runtime/nativeComponents/form.mjs.map +1 -0
- package/dist/runtime/nativeComponents/formControl.mjs +61 -0
- package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
- package/dist/runtime/nativeComponents/helpers.mjs +25 -0
- package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
- package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
- package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/image.d.mts +8 -0
- package/dist/runtime/nativeComponents/image.mjs +121 -0
- package/dist/runtime/nativeComponents/image.mjs.map +1 -0
- package/dist/runtime/nativeComponents/index.d.mts +11 -0
- package/dist/runtime/nativeComponents/index.mjs +83 -0
- package/dist/runtime/nativeComponents/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/input.d.mts +8 -0
- package/dist/runtime/nativeComponents/input.mjs +131 -0
- package/dist/runtime/nativeComponents/input.mjs.map +1 -0
- package/dist/runtime/nativeComponents/label.mjs +36 -0
- package/dist/runtime/nativeComponents/label.mjs.map +1 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
- package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/navigator.mjs +200 -0
- package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
- package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
- package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/primitives.mjs +16 -0
- package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
- package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
- package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/radio.mjs +147 -0
- package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
- package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
- package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
- package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
- package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
- package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/style.mjs +41 -0
- package/dist/runtime/nativeComponents/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/switch.d.mts +7 -0
- package/dist/runtime/nativeComponents/switch.mjs +132 -0
- package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
- package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
- package/dist/runtime/nativeComponents/textarea.mjs +144 -0
- package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/index.mjs +124 -0
- package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/style.mjs +14 -0
- package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
- package/dist/runtime/navigationBar/index.mjs +1 -3
- package/dist/runtime/navigationBar/index.mjs.map +1 -1
- package/dist/runtime/pageLayout.d.mts +9 -0
- package/dist/runtime/pageLayout.mjs +16 -0
- package/dist/runtime/pageLayout.mjs.map +1 -0
- package/dist/runtime/polyfill/animation.mjs +120 -0
- package/dist/runtime/polyfill/animation.mjs.map +1 -0
- package/dist/runtime/polyfill/appState.mjs +1 -1
- package/dist/runtime/polyfill/appState.mjs.map +1 -1
- package/dist/runtime/polyfill/async.d.mts +7 -0
- package/dist/runtime/polyfill/async.mjs.map +1 -1
- package/dist/runtime/polyfill/canvasContext.mjs +41 -0
- package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
- package/dist/runtime/polyfill/device.mjs +1 -1
- package/dist/runtime/polyfill/device.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceApi.mjs +6 -3
- package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/eventBus.mjs +56 -0
- package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
- package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
- package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
- package/dist/runtime/polyfill/files.mjs +10 -10
- package/dist/runtime/polyfill/files.mjs.map +1 -1
- package/dist/runtime/polyfill/font.mjs +33 -0
- package/dist/runtime/polyfill/font.mjs.map +1 -0
- package/dist/runtime/polyfill/index.d.mts +2 -2
- package/dist/runtime/polyfill/index.mjs +49 -45
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/interaction.mjs +7 -6
- package/dist/runtime/polyfill/interaction.mjs.map +1 -1
- package/dist/runtime/polyfill/interactionApi.mjs +9 -5
- package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
- package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
- package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
- package/dist/runtime/polyfill/locale.mjs +14 -0
- package/dist/runtime/polyfill/locale.mjs.map +1 -0
- package/dist/runtime/polyfill/locationApi.mjs +11 -6
- package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaActions.mjs +2 -2
- package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/file.mjs +3 -2
- package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
- package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/picker.mjs +16 -8
- package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +39 -4
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/network/request.mjs +2 -2
- package/dist/runtime/polyfill/network/request.mjs.map +1 -1
- package/dist/runtime/polyfill/platformApi.mjs +3 -2
- package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
- package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
- package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
- package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
- package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
- package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
- package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
- package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
- package/dist/runtime/polyfill/storage.mjs +5 -2
- package/dist/runtime/polyfill/storage.mjs.map +1 -1
- package/dist/runtime/polyfill/storageAsync.mjs +4 -2
- package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
- package/dist/runtime/polyfill/system.mjs +31 -4
- package/dist/runtime/polyfill/system.mjs.map +1 -1
- package/dist/runtime/polyfill/systemApi.mjs +2 -1
- package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
- package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
- package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
- package/dist/runtime/polyfill/ui.mjs +2 -6
- package/dist/runtime/polyfill/ui.mjs.map +1 -1
- package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
- package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
- package/dist/runtime/polyfill/videoContext.mjs +4 -0
- package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
- package/dist/runtime/polyfill/vkSession.mjs +4 -14
- package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
- package/dist/runtime/polyfill.d.mts +2 -2
- package/dist/runtime/renderContext.mjs +1 -1
- package/dist/runtime/renderContext.mjs.map +1 -1
- package/dist/runtime/rpx.mjs +17 -8
- package/dist/runtime/rpx.mjs.map +1 -1
- package/dist/runtime/seo/index.d.mts +31 -0
- package/dist/runtime/seo/index.mjs +94 -0
- package/dist/runtime/seo/index.mjs.map +1 -0
- package/dist/runtime/viewport/index.d.mts +12 -0
- package/dist/runtime/viewport/index.mjs +44 -0
- package/dist/runtime/viewport/index.mjs.map +1 -0
- package/dist/runtime/viewport/style.mjs +62 -0
- package/dist/runtime/viewport/style.mjs.map +1 -0
- package/dist/runtime/viewport/types.d.mts +14 -0
- package/dist/runtime/wevu.d.mts +20 -0
- package/dist/runtime/wevu.mjs +73 -0
- package/dist/runtime/wevu.mjs.map +1 -0
- package/dist/shared/nativeComponents.mjs +401 -0
- package/dist/shared/nativeComponents.mjs.map +1 -0
- package/dist/shared/tabBar.d.mts +19 -0
- package/dist/shared/tabBar.mjs +37 -0
- package/dist/shared/tabBar.mjs.map +1 -0
- package/dist/shared/wxml.mjs +3 -20
- package/dist/shared/wxml.mjs.map +1 -1
- package/package.json +14 -6
package/dist/plugin/index.mjs
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { transformWxssToCss } from "../css/wxss.mjs";
|
|
1
|
+
import { createWxssPostcssPlugin, transformWxssToCss } from "../css/wxss.mjs";
|
|
2
2
|
import { compileWxml } from "../compiler/wxml/compile.mjs";
|
|
3
3
|
import { transformWxsToEsm } from "../compiler/wxs.mjs";
|
|
4
|
-
import { ENTRY_ID, SCRIPT_EXTS, STYLE_EXTS, TEMPLATE_EXTS, TRANSFORM_STYLE_EXTS, WXS_EXTS } from "./constants.mjs";
|
|
5
|
-
import { cleanUrl, isHtmlEntry, isInsideDir, normalizePath, resolveTemplatePathSync, resolveWxsPathSync, toRelativeImport } from "./path.mjs";
|
|
6
|
-
import {
|
|
4
|
+
import { AUTO_ROUTES_ID, ENTRY_ID, RESOLVED_AUTO_ROUTES_ID, SCRIPT_EXTS, SFC_STYLE_QUERY, SFC_TEMPLATE_QUERY, STYLE_EXTS, STYLE_QUERY, TEMPLATE_EXTS, TEMPLATE_QUERY, TRANSFORM_STYLE_EXTS, WEB_COMPONENT_PREFIX, WEB_COMPONENT_QUERY, WXS_EXTS } from "./constants.mjs";
|
|
5
|
+
import { cleanUrl, isHtmlEntry, isInsideDir, normalizePath, resolveFileWithExtensionsSync, resolveRuntimePolyfillPath, resolveTemplatePathSync, resolveWxsPathSync, toRelativeImport, toViteFsImport } from "./path.mjs";
|
|
6
|
+
import { createWebAssetMiddleware, emitWebAssets } from "./assets.mjs";
|
|
7
|
+
import { collectExternalComponentOptimizeDeps } from "./dependencyScan.mjs";
|
|
8
|
+
import { generateAutoRoutesModule, generateEntryModule } from "./entry.mjs";
|
|
9
|
+
import { wrapPageTemplate } from "./layout.mjs";
|
|
7
10
|
import { transformScriptModule } from "./register.mjs";
|
|
8
|
-
import {
|
|
11
|
+
import { ensureWebVueSfcResult, generateWebVueSfcStyle, generateWebVueSfcTemplate, resolveWebVueSfcStyleLanguage, transformWebVueSfcScript } from "./vueSfc.mjs";
|
|
12
|
+
import { getStableWebComponentId, scanProject } from "./scan.mjs";
|
|
9
13
|
import { createEmptyScanState } from "./state.mjs";
|
|
14
|
+
import { createInlineStyleModule } from "./styleModule.mjs";
|
|
15
|
+
import { readFile } from "node:fs/promises";
|
|
10
16
|
import process from "node:process";
|
|
11
|
-
import { extname, resolve } from "pathe";
|
|
17
|
+
import { dirname, extname, resolve } from "pathe";
|
|
18
|
+
import { isUniAppCompatibilityFile, transformUniAppSource } from "wevu/compiler";
|
|
12
19
|
|
|
13
20
|
//#region src/plugin/index.ts
|
|
14
21
|
function isTemplateFile(id) {
|
|
@@ -22,101 +29,257 @@ function isWxsFile(id) {
|
|
|
22
29
|
function hasWxsQuery(id) {
|
|
23
30
|
return id.includes("?wxs") || id.includes("&wxs");
|
|
24
31
|
}
|
|
25
|
-
function
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
` return () => {}`,
|
|
49
|
-
` }`,
|
|
50
|
-
` const styleId = id ?? __weapp_createStyleId__(css)`,
|
|
51
|
-
` const existing = __weapp_injected_styles__.get(styleId)`,
|
|
52
|
-
` if (existing) {`,
|
|
53
|
-
` if (existing.textContent !== css) {`,
|
|
54
|
-
` existing.textContent = css`,
|
|
55
|
-
` }`,
|
|
56
|
-
` return () => __weapp_removeStyle__(styleId)`,
|
|
57
|
-
` }`,
|
|
58
|
-
` const style = document.createElement('style')`,
|
|
59
|
-
` style.id = styleId`,
|
|
60
|
-
` style.textContent = css`,
|
|
61
|
-
` document.head.append(style)`,
|
|
62
|
-
` __weapp_injected_styles__.set(styleId, style)`,
|
|
63
|
-
` return () => __weapp_removeStyle__(styleId)`,
|
|
64
|
-
`}`,
|
|
65
|
-
`const css = ${JSON.stringify(css)}`,
|
|
66
|
-
`export default css`,
|
|
67
|
-
`export function useStyle(id) {`,
|
|
68
|
-
` return injectStyle(css, id)`,
|
|
69
|
-
`}`
|
|
70
|
-
].join("\n");
|
|
32
|
+
function hasQuery(id, query) {
|
|
33
|
+
return id.includes(`?${query}`) || id.includes(`&${query}`);
|
|
34
|
+
}
|
|
35
|
+
function isUniAppDependency(id, includes) {
|
|
36
|
+
return includes.some((packageName) => id === packageName || id.startsWith(`${packageName}/`));
|
|
37
|
+
}
|
|
38
|
+
function resolveSfcStyleSourceFilename(id) {
|
|
39
|
+
const filename = cleanUrl(id);
|
|
40
|
+
const vueSuffixIndex = filename.lastIndexOf(".vue.");
|
|
41
|
+
return vueSuffixIndex >= 0 ? filename.slice(0, vueSuffixIndex + 4) : filename;
|
|
42
|
+
}
|
|
43
|
+
function createWebCssConfig(config, wxssOptions, warn) {
|
|
44
|
+
const postcssConfig = config.css?.postcss;
|
|
45
|
+
if (typeof postcssConfig === "string") {
|
|
46
|
+
warn?.("[@weapp-vite/web] css.postcss 使用配置文件路径时无法注入 WXSS 转换插件。");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const plugins = postcssConfig?.plugins ?? [];
|
|
50
|
+
if (plugins.some((plugin) => plugin.postcssPlugin === "weapp-vite-web-wxss")) return;
|
|
51
|
+
return { postcss: {
|
|
52
|
+
...postcssConfig,
|
|
53
|
+
plugins: [...plugins, createWxssPostcssPlugin(wxssOptions)]
|
|
54
|
+
} };
|
|
71
55
|
}
|
|
72
56
|
function weappWebPlugin(options = {}) {
|
|
73
57
|
let root = process.cwd();
|
|
74
58
|
let srcRoot = resolve(root, options.srcDir ?? "src");
|
|
75
59
|
let enableHmr = false;
|
|
60
|
+
let resolveWebModuleId;
|
|
61
|
+
let resolveWebAutoImportTag;
|
|
62
|
+
const componentImportIdMap = /* @__PURE__ */ new Map();
|
|
76
63
|
const state = createEmptyScanState();
|
|
77
64
|
const wxssOptions = options.wxss;
|
|
78
65
|
const runtimeProvider = options.__runtimeProvider;
|
|
79
66
|
const hmrAcceptCode = runtimeProvider ? runtimeProvider.hmrAcceptCode : "if (import.meta.hot) { import.meta.hot.accept() }";
|
|
80
67
|
const resolveTemplatePath = (raw, importer) => resolveTemplatePathSync(raw, importer, srcRoot);
|
|
81
68
|
const resolveWxsPath = (raw, importer) => resolveWxsPathSync(raw, importer, srcRoot);
|
|
69
|
+
const resolveMetaByTemplate = (filename) => {
|
|
70
|
+
const normalized = normalizePath(filename);
|
|
71
|
+
for (const meta of state.moduleMeta.values()) if (meta.templatePath && normalizePath(meta.templatePath) === normalized) return meta;
|
|
72
|
+
};
|
|
73
|
+
const createAutoImportTagResolver = () => {
|
|
74
|
+
const resolvers = options.__autoImportResolvers;
|
|
75
|
+
if (!resolvers?.length) return;
|
|
76
|
+
return async (tag, importer) => {
|
|
77
|
+
for (const resolver of resolvers) {
|
|
78
|
+
let matched;
|
|
79
|
+
if (typeof resolver === "function") matched = resolver(tag, importer);
|
|
80
|
+
else if (typeof resolver.resolve === "function") matched = resolver.resolve(tag, importer);
|
|
81
|
+
else {
|
|
82
|
+
const from = resolver.components?.[tag];
|
|
83
|
+
matched = from ? {
|
|
84
|
+
name: tag,
|
|
85
|
+
from
|
|
86
|
+
} : void 0;
|
|
87
|
+
}
|
|
88
|
+
if (!matched) continue;
|
|
89
|
+
const request = matched.resolvedId ?? matched.from;
|
|
90
|
+
const resolvedId = await resolveWebModuleId?.(request, importer);
|
|
91
|
+
return {
|
|
92
|
+
...matched,
|
|
93
|
+
resolvedId: resolvedId ?? matched.resolvedId,
|
|
94
|
+
sourceType: matched.sourceType ?? (resolvedId?.endsWith(".vue") ? "wevu-sfc" : "native")
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const scan = async (context) => {
|
|
100
|
+
await scanProject({
|
|
101
|
+
srcRoot,
|
|
102
|
+
warn: context.warn?.bind(context),
|
|
103
|
+
state,
|
|
104
|
+
resolveId: resolveWebModuleId,
|
|
105
|
+
resolveAutoImportTag: resolveWebAutoImportTag,
|
|
106
|
+
resolveAppConfig: options.__resolveAppConfig,
|
|
107
|
+
uniApp: options.__uniApp
|
|
108
|
+
});
|
|
109
|
+
componentImportIdMap.clear();
|
|
110
|
+
for (const component of state.scanResult.components) if (component.importId) componentImportIdMap.set(component.importId, component.script);
|
|
111
|
+
};
|
|
82
112
|
return {
|
|
83
113
|
name: "@weapp-vite/web",
|
|
84
114
|
enforce: "pre",
|
|
115
|
+
config(config) {
|
|
116
|
+
const css = createWebCssConfig(config, wxssOptions, this.warn?.bind(this));
|
|
117
|
+
return css ? { css } : void 0;
|
|
118
|
+
},
|
|
85
119
|
async configResolved(config) {
|
|
86
120
|
root = config.root;
|
|
87
121
|
srcRoot = resolve(root, options.srcDir ?? "src");
|
|
88
122
|
enableHmr = config.command === "serve";
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
123
|
+
resolveWebModuleId = config.createResolver?.();
|
|
124
|
+
resolveWebAutoImportTag = createAutoImportTagResolver();
|
|
125
|
+
await scan(this);
|
|
126
|
+
const componentDependencies = await collectExternalComponentOptimizeDeps(state.scanResult.components);
|
|
127
|
+
const uniAppIncludes = options.__uniApp?.include ?? [];
|
|
128
|
+
config.optimizeDeps ??= {};
|
|
129
|
+
config.optimizeDeps.exclude = Array.from(/* @__PURE__ */ new Set([...config.optimizeDeps.exclude ?? [], ...uniAppIncludes]));
|
|
130
|
+
config.optimizeDeps.include = Array.from(/* @__PURE__ */ new Set([...config.optimizeDeps.include ?? [], ...componentDependencies])).filter((dependency) => !isUniAppDependency(dependency, uniAppIncludes));
|
|
131
|
+
},
|
|
132
|
+
configureServer(server) {
|
|
133
|
+
server.middlewares.use(createWebAssetMiddleware(srcRoot));
|
|
94
134
|
},
|
|
95
135
|
async buildStart() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
136
|
+
if (!resolveWebModuleId && this.resolve) resolveWebModuleId = async (source, importer) => {
|
|
137
|
+
return (await this.resolve?.(source, importer, { skipSelf: true }))?.id;
|
|
138
|
+
};
|
|
139
|
+
resolveWebAutoImportTag = createAutoImportTagResolver();
|
|
140
|
+
await scan(this);
|
|
141
|
+
if (!enableHmr) await emitWebAssets(this, srcRoot);
|
|
101
142
|
},
|
|
102
|
-
resolveId(id) {
|
|
143
|
+
resolveId(id, importer) {
|
|
103
144
|
if (id === "/@weapp-vite/web/entry" || id === "@weapp-vite/web/entry") return ENTRY_ID;
|
|
145
|
+
if (id === "weapp-vite/auto-routes") return RESOLVED_AUTO_ROUTES_ID;
|
|
146
|
+
if (id.startsWith("/@weapp-vite/web/component/")) {
|
|
147
|
+
const request = decodeURIComponent(id.slice(WEB_COMPONENT_PREFIX.length));
|
|
148
|
+
const resolvedId = componentImportIdMap.get(request);
|
|
149
|
+
return resolvedId ? `${cleanUrl(resolvedId)}?${WEB_COMPONENT_QUERY}` : null;
|
|
150
|
+
}
|
|
151
|
+
if (id.startsWith(".") && importer && cleanUrl(importer).endsWith(".vue") && !extname(id)) {
|
|
152
|
+
const resolvedScript = resolveFileWithExtensionsSync(resolve(dirname(cleanUrl(importer)), id), SCRIPT_EXTS);
|
|
153
|
+
if (resolvedScript?.endsWith(".vue")) return resolvedScript;
|
|
154
|
+
}
|
|
155
|
+
if (hasQuery(id, "weapp-web-sfc-style")) {
|
|
156
|
+
const queryIndex = id.indexOf("?");
|
|
157
|
+
const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;
|
|
158
|
+
const query = queryIndex >= 0 ? id.slice(queryIndex) : "";
|
|
159
|
+
if (pathname.startsWith(".") && importer) return `${resolve(dirname(cleanUrl(importer)), pathname)}${query}`;
|
|
160
|
+
return id;
|
|
161
|
+
}
|
|
104
162
|
return null;
|
|
105
163
|
},
|
|
106
|
-
load(id) {
|
|
164
|
+
async load(id) {
|
|
107
165
|
if (id === "\0@weapp-vite/web/entry") return generateEntryModule(state.scanResult, root, wxssOptions, options);
|
|
166
|
+
if (id === "\0@weapp-vite/web/auto-routes") return generateAutoRoutesModule(state.scanResult);
|
|
167
|
+
if (hasQuery(id, "weapp-web-template")) {
|
|
168
|
+
const filename = cleanUrl(id);
|
|
169
|
+
let source = await readFile(filename, "utf8");
|
|
170
|
+
if (resolveMetaByTemplate(filename)?.kind === "page" && state.scanResult.layouts.length) source = wrapPageTemplate(source, state.scanResult.layouts);
|
|
171
|
+
const navigationConfig = state.pageNavigationMap.get(normalizePath(filename));
|
|
172
|
+
const componentTags = state.templateComponentMap.get(normalizePath(filename));
|
|
173
|
+
const compiled = compileWxml({
|
|
174
|
+
id: filename,
|
|
175
|
+
source,
|
|
176
|
+
resolveTemplatePath,
|
|
177
|
+
resolveWxsPath,
|
|
178
|
+
navigationBar: navigationConfig ? { config: navigationConfig } : void 0,
|
|
179
|
+
componentTags
|
|
180
|
+
});
|
|
181
|
+
for (const dependency of compiled.dependencies) this.addWatchFile?.(dependency);
|
|
182
|
+
for (const warning of compiled.warnings ?? []) this.warn?.(warning);
|
|
183
|
+
return compiled.code;
|
|
184
|
+
}
|
|
185
|
+
if (hasWxsQuery(id)) {
|
|
186
|
+
const filename = cleanUrl(id);
|
|
187
|
+
const source = await readFile(filename, "utf8");
|
|
188
|
+
const compiled = transformWxsToEsm(source, filename, {
|
|
189
|
+
resolvePath: resolveWxsPath,
|
|
190
|
+
toImportPath: (resolved, importer) => normalizePath(toRelativeImport(importer, resolved))
|
|
191
|
+
});
|
|
192
|
+
for (const dependency of compiled.dependencies) this.addWatchFile?.(dependency);
|
|
193
|
+
for (const warning of compiled.warnings ?? []) this.warn?.(warning);
|
|
194
|
+
return compiled.code;
|
|
195
|
+
}
|
|
196
|
+
if (hasQuery(id, "weapp-web-style")) {
|
|
197
|
+
const source = await readFile(cleanUrl(id), "utf8");
|
|
198
|
+
const { css } = transformWxssToCss(source, wxssOptions);
|
|
199
|
+
return createInlineStyleModule(css);
|
|
200
|
+
}
|
|
201
|
+
if (id.includes(`?${"weapp-web-sfc-template"}`) || id.includes(`&${"weapp-web-sfc-template"}`)) {
|
|
202
|
+
const filename = cleanUrl(id);
|
|
203
|
+
const meta = state.moduleMeta.get(normalizePath(filename));
|
|
204
|
+
if (!meta) return null;
|
|
205
|
+
const result = await ensureWebVueSfcResult({
|
|
206
|
+
filename,
|
|
207
|
+
meta,
|
|
208
|
+
srcRoot,
|
|
209
|
+
state,
|
|
210
|
+
resolveId: resolveWebModuleId,
|
|
211
|
+
resolveAutoImportTag: resolveWebAutoImportTag,
|
|
212
|
+
uniApp: options.__uniApp
|
|
213
|
+
});
|
|
214
|
+
const compiled = generateWebVueSfcTemplate(result, meta, filename, srcRoot);
|
|
215
|
+
for (const dependency of compiled.dependencies) this.addWatchFile?.(dependency);
|
|
216
|
+
for (const warning of compiled.warnings ?? []) this.warn?.(warning);
|
|
217
|
+
return compiled.code;
|
|
218
|
+
}
|
|
219
|
+
if (id.includes(`?${"weapp-web-sfc-style"}`) || id.includes(`&${"weapp-web-sfc-style"}`)) {
|
|
220
|
+
const filename = resolveSfcStyleSourceFilename(id);
|
|
221
|
+
const meta = state.moduleMeta.get(normalizePath(filename));
|
|
222
|
+
if (!meta) return null;
|
|
223
|
+
const result = await ensureWebVueSfcResult({
|
|
224
|
+
filename,
|
|
225
|
+
meta,
|
|
226
|
+
srcRoot,
|
|
227
|
+
state,
|
|
228
|
+
resolveId: resolveWebModuleId,
|
|
229
|
+
resolveAutoImportTag: resolveWebAutoImportTag,
|
|
230
|
+
uniApp: options.__uniApp
|
|
231
|
+
});
|
|
232
|
+
return generateWebVueSfcStyle(result);
|
|
233
|
+
}
|
|
108
234
|
return null;
|
|
109
235
|
},
|
|
110
236
|
async handleHotUpdate(ctx) {
|
|
111
237
|
const clean = cleanUrl(ctx.file);
|
|
112
|
-
if (clean.endsWith(".json") || isTemplateFile(clean) || isWxsFile(clean) || clean.endsWith(".wxss") || SCRIPT_EXTS.includes(extname(clean))) await
|
|
113
|
-
srcRoot,
|
|
114
|
-
warn: this.warn?.bind(this),
|
|
115
|
-
state
|
|
116
|
-
});
|
|
238
|
+
if (clean.endsWith(".json") || isTemplateFile(clean) || isWxsFile(clean) || clean.endsWith(".wxss") || SCRIPT_EXTS.includes(extname(clean))) await scan(this);
|
|
117
239
|
},
|
|
118
|
-
transform(code, id) {
|
|
240
|
+
async transform(code, id) {
|
|
119
241
|
const clean = cleanUrl(id);
|
|
242
|
+
let uniAppTransformed = false;
|
|
243
|
+
if (options.__uniApp && isUniAppCompatibilityFile(clean, srcRoot, options.__uniApp.include) && !clean.endsWith(".vue")) {
|
|
244
|
+
const transformed = transformUniAppSource(code, {
|
|
245
|
+
filename: clean,
|
|
246
|
+
target: "h5"
|
|
247
|
+
});
|
|
248
|
+
if (transformed.changed) {
|
|
249
|
+
code = transformed.code;
|
|
250
|
+
uniAppTransformed = true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (hasQuery(id, "weapp-web-template") || hasWxsQuery(id) || hasQuery(id, "weapp-web-style") || hasQuery(id, "weapp-web-sfc-template") || hasQuery(id, "weapp-web-sfc-style")) return null;
|
|
254
|
+
if (clean.endsWith(".vue")) {
|
|
255
|
+
const normalized = normalizePath(clean);
|
|
256
|
+
const meta = state.moduleMeta.get(normalized) ?? {
|
|
257
|
+
kind: "component",
|
|
258
|
+
id: getStableWebComponentId(clean, srcRoot),
|
|
259
|
+
scriptPath: clean,
|
|
260
|
+
sourceType: "vue-sfc"
|
|
261
|
+
};
|
|
262
|
+
state.moduleMeta.set(normalized, meta);
|
|
263
|
+
const result = await ensureWebVueSfcResult({
|
|
264
|
+
filename: clean,
|
|
265
|
+
meta,
|
|
266
|
+
srcRoot,
|
|
267
|
+
state,
|
|
268
|
+
source: code,
|
|
269
|
+
resolveId: resolveWebModuleId,
|
|
270
|
+
resolveAutoImportTag: resolveWebAutoImportTag,
|
|
271
|
+
uniApp: options.__uniApp
|
|
272
|
+
});
|
|
273
|
+
return transformWebVueSfcScript({
|
|
274
|
+
code: result.script,
|
|
275
|
+
filename: clean,
|
|
276
|
+
meta,
|
|
277
|
+
runtimeModuleId: runtimeProvider?.moduleId ?? toViteFsImport(resolveRuntimePolyfillPath()),
|
|
278
|
+
styleLanguage: resolveWebVueSfcStyleLanguage(result, clean),
|
|
279
|
+
enableHmr,
|
|
280
|
+
hmrAcceptCode
|
|
281
|
+
});
|
|
282
|
+
}
|
|
120
283
|
if (isTemplateFile(clean)) {
|
|
121
284
|
if (isHtmlEntry(clean, root)) return null;
|
|
122
285
|
const normalizedId = normalizePath(clean);
|
|
@@ -124,11 +287,13 @@ function weappWebPlugin(options = {}) {
|
|
|
124
287
|
if (!isInsideDir(clean, srcRoot)) return null;
|
|
125
288
|
if (!state.templatePathSet.has(normalizedId)) return null;
|
|
126
289
|
}
|
|
290
|
+
let templateSource = code;
|
|
291
|
+
if (resolveMetaByTemplate(clean)?.kind === "page" && state.scanResult.layouts.length) templateSource = wrapPageTemplate(code, state.scanResult.layouts);
|
|
127
292
|
const navigationConfig = state.pageNavigationMap.get(normalizedId);
|
|
128
293
|
const componentTags = state.templateComponentMap.get(normalizedId);
|
|
129
294
|
const { code: compiled, dependencies, warnings } = compileWxml({
|
|
130
295
|
id: clean,
|
|
131
|
-
source:
|
|
296
|
+
source: templateSource,
|
|
132
297
|
resolveTemplatePath,
|
|
133
298
|
resolveWxsPath,
|
|
134
299
|
navigationBar: navigationConfig ? { config: navigationConfig } : void 0,
|
|
@@ -171,8 +336,14 @@ function weappWebPlugin(options = {}) {
|
|
|
171
336
|
map: null
|
|
172
337
|
};
|
|
173
338
|
}
|
|
174
|
-
if (!SCRIPT_EXTS.some((ext) => clean.endsWith(ext))) return
|
|
175
|
-
|
|
339
|
+
if (!SCRIPT_EXTS.some((ext) => clean.endsWith(ext))) return uniAppTransformed ? {
|
|
340
|
+
code,
|
|
341
|
+
map: null
|
|
342
|
+
} : null;
|
|
343
|
+
if (clean.includes("node_modules") && !hasQuery(id, "weapp-web-component")) return options.__uniApp && isUniAppCompatibilityFile(clean, srcRoot, options.__uniApp.include) ? {
|
|
344
|
+
code,
|
|
345
|
+
map: null
|
|
346
|
+
} : null;
|
|
176
347
|
const meta = state.moduleMeta.get(normalizePath(clean));
|
|
177
348
|
if (!meta) return null;
|
|
178
349
|
return transformScriptModule({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/plugin/index.ts"],"sourcesContent":["import type { SourceMap } from 'magic-string'\nimport type { WeappWebPluginOptions } from './types'\nimport process from 'node:process'\n\nimport { extname, resolve } from 'pathe'\nimport { compileWxml } from '../compiler/wxml'\nimport { transformWxsToEsm } from '../compiler/wxs'\nimport { transformWxssToCss } from '../css/wxss'\nimport { ENTRY_ID, SCRIPT_EXTS, STYLE_EXTS, TEMPLATE_EXTS, TRANSFORM_STYLE_EXTS, WXS_EXTS } from './constants'\nimport { generateEntryModule } from './entry'\nimport { cleanUrl, isHtmlEntry, isInsideDir, normalizePath, resolveTemplatePathSync, resolveWxsPathSync, toRelativeImport } from './path'\nimport { transformScriptModule } from './register'\nimport { scanProject } from './scan'\nimport { createEmptyScanState } from './state'\n\ninterface WebPluginContext {\n warn?: (message: string) => void\n addWatchFile?: (id: string) => void\n}\n\ntype WebTransformResult = { code: string, map: SourceMap | null } | null\n\ninterface WebResolvedConfig {\n root: string\n command: string\n}\n\ninterface WebHmrContext {\n file: string\n}\n\ninterface WeappWebVitePlugin {\n name: string\n enforce?: 'pre' | 'post'\n configResolved?: (this: WebPluginContext, config: WebResolvedConfig) => void | Promise<void>\n buildStart?: (this: WebPluginContext) => void | Promise<void>\n resolveId?: (id: string) => string | null | Promise<string | null>\n load?: (id: string) => string | null | Promise<string | null>\n handleHotUpdate?: (this: WebPluginContext, ctx: WebHmrContext) => void | Promise<void>\n transform?: (\n this: WebPluginContext,\n code: string,\n id: string,\n ) => WebTransformResult | Promise<WebTransformResult>\n}\n\nfunction isTemplateFile(id: string) {\n const lower = id.toLowerCase()\n return TEMPLATE_EXTS.some(ext => lower.endsWith(ext))\n}\n\nfunction isWxsFile(id: string) {\n const lower = id.toLowerCase()\n return WXS_EXTS.some(ext => lower.endsWith(ext))\n}\n\nfunction hasWxsQuery(id: string) {\n return id.includes('?wxs') || id.includes('&wxs')\n}\n\nfunction createInlineStyleModule(css: string) {\n const serialized = JSON.stringify(css)\n return [\n `const __weapp_injected_styles__ = new Map()`,\n `function __weapp_createStyleId__(css) {`,\n ` let hash = 2166136261`,\n ` for (let i = 0; i < css.length; i++) {`,\n ` hash ^= css.charCodeAt(i)`,\n ` hash += (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24)`,\n ` }`,\n ` return 'weapp-web-style-' + (hash >>> 0).toString(36)`,\n `}`,\n `function __weapp_removeStyle__(id) {`,\n ` if (typeof document === 'undefined') {`,\n ` return`,\n ` }`,\n ` const style = __weapp_injected_styles__.get(id)`,\n ` if (style) {`,\n ` style.remove()`,\n ` __weapp_injected_styles__.delete(id)`,\n ` }`,\n `}`,\n `function injectStyle(css, id) {`,\n ` if (typeof document === 'undefined') {`,\n ` return () => {}`,\n ` }`,\n ` const styleId = id ?? __weapp_createStyleId__(css)`,\n ` const existing = __weapp_injected_styles__.get(styleId)`,\n ` if (existing) {`,\n ` if (existing.textContent !== css) {`,\n ` existing.textContent = css`,\n ` }`,\n ` return () => __weapp_removeStyle__(styleId)`,\n ` }`,\n ` const style = document.createElement('style')`,\n ` style.id = styleId`,\n ` style.textContent = css`,\n ` document.head.append(style)`,\n ` __weapp_injected_styles__.set(styleId, style)`,\n ` return () => __weapp_removeStyle__(styleId)`,\n `}`,\n `const css = ${serialized}`,\n `export default css`,\n `export function useStyle(id) {`,\n ` return injectStyle(css, id)`,\n `}`,\n ].join('\\n')\n}\n\nexport function weappWebPlugin(options: WeappWebPluginOptions = {}): WeappWebVitePlugin {\n let root = process.cwd()\n let srcRoot = resolve(root, options.srcDir ?? 'src')\n let enableHmr = false\n\n const state = createEmptyScanState()\n const wxssOptions = options.wxss\n const runtimeProvider = options.__runtimeProvider\n const hmrAcceptCode = runtimeProvider\n ? runtimeProvider.hmrAcceptCode\n : 'if (import.meta.hot) { import.meta.hot.accept() }'\n\n const resolveTemplatePath = (raw: string, importer: string) => resolveTemplatePathSync(raw, importer, srcRoot)\n const resolveWxsPath = (raw: string, importer: string) => resolveWxsPathSync(raw, importer, srcRoot)\n\n return {\n name: '@weapp-vite/web',\n enforce: 'pre',\n async configResolved(this: WebPluginContext, config: WebResolvedConfig) {\n root = config.root\n srcRoot = resolve(root, options.srcDir ?? 'src')\n enableHmr = config.command === 'serve'\n await scanProject({ srcRoot, warn: this.warn?.bind(this), state })\n },\n async buildStart(this: WebPluginContext) {\n await scanProject({ srcRoot, warn: this.warn?.bind(this), state })\n },\n resolveId(id: string) {\n if (id === '/@weapp-vite/web/entry' || id === '@weapp-vite/web/entry') {\n return ENTRY_ID\n }\n return null\n },\n load(id: string) {\n if (id === ENTRY_ID) {\n return generateEntryModule(state.scanResult, root, wxssOptions, options)\n }\n return null\n },\n async handleHotUpdate(this: WebPluginContext, ctx: WebHmrContext) {\n const clean = cleanUrl(ctx.file)\n if (clean.endsWith('.json') || isTemplateFile(clean) || isWxsFile(clean) || clean.endsWith('.wxss') || SCRIPT_EXTS.includes(extname(clean))) {\n await scanProject({ srcRoot, warn: this.warn?.bind(this), state })\n }\n },\n transform(this: WebPluginContext, code: string, id: string) {\n const clean = cleanUrl(id)\n\n if (isTemplateFile(clean)) {\n if (isHtmlEntry(clean, root)) {\n return null\n }\n const normalizedId = normalizePath(clean)\n if (state.templatePathSet.size > 0) {\n if (!isInsideDir(clean, srcRoot)) {\n return null\n }\n if (!state.templatePathSet.has(normalizedId)) {\n return null\n }\n }\n const navigationConfig = state.pageNavigationMap.get(normalizedId)\n const componentTags = state.templateComponentMap.get(normalizedId)\n const { code: compiled, dependencies, warnings } = compileWxml({\n id: clean,\n source: code,\n resolveTemplatePath,\n resolveWxsPath,\n navigationBar: navigationConfig ? { config: navigationConfig } : undefined,\n componentTags,\n })\n const addWatchFile = this.addWatchFile\n if (dependencies.length > 0 && addWatchFile) {\n for (const dep of dependencies) {\n addWatchFile.call(this, dep)\n }\n }\n const warn = this.warn\n if (warnings?.length && warn) {\n for (const warning of warnings) {\n warn.call(this, warning)\n }\n }\n return { code: compiled, map: null }\n }\n\n if (isWxsFile(clean) || hasWxsQuery(id)) {\n const { code: compiled, dependencies, warnings } = transformWxsToEsm(code, clean, {\n resolvePath: resolveWxsPath,\n toImportPath: (resolved, importer) => normalizePath(toRelativeImport(importer, resolved)),\n })\n const addWatchFile = this.addWatchFile\n if (dependencies.length > 0 && addWatchFile) {\n for (const dep of dependencies) {\n addWatchFile.call(this, dep)\n }\n }\n const warn = this.warn\n if (warnings?.length && warn) {\n for (const warning of warnings) {\n warn.call(this, warning)\n }\n }\n return { code: compiled, map: null }\n }\n\n if (TRANSFORM_STYLE_EXTS.some(ext => clean.endsWith(ext))) {\n const { css } = transformWxssToCss(code, wxssOptions)\n return {\n code: createInlineStyleModule(css),\n map: null,\n }\n }\n\n if (STYLE_EXTS.some(ext => clean.endsWith(ext)) && !clean.endsWith('.wxss')) {\n const { css } = transformWxssToCss(code, wxssOptions)\n return { code: css, map: null }\n }\n\n if (!SCRIPT_EXTS.some(ext => clean.endsWith(ext))) {\n return null\n }\n if (clean.includes('node_modules')) {\n return null\n }\n\n const meta = state.moduleMeta.get(normalizePath(clean))\n if (!meta) {\n return null\n }\n\n return transformScriptModule({\n code,\n cleanId: clean,\n meta,\n enableHmr,\n runtimeModuleId: runtimeProvider?.moduleId,\n hmrAcceptCode,\n })\n },\n }\n}\n\nexport type { WeappWebPluginOptions } from './types'\n"],"mappings":";;;;;;;;;;;;;AA8CA,SAAS,eAAe,IAAY;CAClC,MAAM,QAAQ,GAAG,YAAY;CAC7B,OAAO,cAAc,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC;AACtD;AAEA,SAAS,UAAU,IAAY;CAC7B,MAAM,QAAQ,GAAG,YAAY;CAC7B,OAAO,SAAS,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC;AACjD;AAEA,SAAS,YAAY,IAAY;CAC/B,OAAO,GAAG,SAAS,MAAM,KAAK,GAAG,SAAS,MAAM;AAClD;AAEA,SAAS,wBAAwB,KAAa;CAE5C,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAxCiB,KAAK,UAAU,GAwCR;EACxB;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;KAAU,KAAK;IAAK;GACrC;GAEA,IAAI,qBAAqB,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAAG;IACzD,MAAM,EAAE,QAAQ,mBAAmB,MAAM,WAAW;IACpD,OAAO;KACL,MAAM,wBAAwB,GAAG;KACjC,KAAK;IACP;GACF;GAEA,IAAI,WAAW,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,KAAK,CAAC,MAAM,SAAS,OAAO,GAAG;IAC3E,MAAM,EAAE,QAAQ,mBAAmB,MAAM,WAAW;IACpD,OAAO;KAAE,MAAM;KAAK,KAAK;IAAK;GAChC;GAEA,IAAI,CAAC,YAAY,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC,GAC9C,OAAO;GAET,IAAI,MAAM,SAAS,cAAc,GAC/B,OAAO;GAGT,MAAM,OAAO,MAAM,WAAW,IAAI,cAAc,KAAK,CAAC;GACtD,IAAI,CAAC,MACH,OAAO;GAGT,OAAO,sBAAsB;IAC3B;IACA,SAAS;IACT;IACA;IACA,iBAAiB,iBAAiB;IAClC;GACF,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/plugin/index.ts"],"sourcesContent":["import type { SourceMap } from 'magic-string'\nimport type { ResolveWebAutoImportTag, ResolveWebModuleId, WeappWebPluginOptions, WebResolvedComponent } from './types'\nimport { readFile } from 'node:fs/promises'\nimport process from 'node:process'\n\nimport { dirname, extname, resolve } from 'pathe'\nimport { isUniAppCompatibilityFile, transformUniAppSource } from 'wevu/compiler'\nimport { compileWxml } from '../compiler/wxml'\nimport { transformWxsToEsm } from '../compiler/wxs'\nimport { createWxssPostcssPlugin, transformWxssToCss } from '../css/wxss'\nimport { createWebAssetMiddleware, emitWebAssets } from './assets'\nimport { AUTO_ROUTES_ID, ENTRY_ID, RESOLVED_AUTO_ROUTES_ID, SCRIPT_EXTS, SFC_STYLE_QUERY, SFC_TEMPLATE_QUERY, STYLE_EXTS, STYLE_QUERY, TEMPLATE_EXTS, TEMPLATE_QUERY, TRANSFORM_STYLE_EXTS, WEB_COMPONENT_PREFIX, WEB_COMPONENT_QUERY, WXS_EXTS } from './constants'\nimport { collectExternalComponentOptimizeDeps } from './dependencyScan'\nimport { generateAutoRoutesModule, generateEntryModule } from './entry'\nimport { wrapPageTemplate } from './layout'\nimport { cleanUrl, isHtmlEntry, isInsideDir, normalizePath, resolveFileWithExtensionsSync, resolveRuntimePolyfillPath, resolveTemplatePathSync, resolveWxsPathSync, toRelativeImport, toViteFsImport } from './path'\nimport { transformScriptModule } from './register'\nimport { getStableWebComponentId, scanProject } from './scan'\nimport { createEmptyScanState } from './state'\nimport { createInlineStyleModule } from './styleModule'\nimport { ensureWebVueSfcResult, generateWebVueSfcStyle, generateWebVueSfcTemplate, resolveWebVueSfcStyleLanguage, transformWebVueSfcScript } from './vueSfc'\n\ninterface WebPluginContext {\n warn?: (message: string) => void\n addWatchFile?: (id: string) => void\n emitFile?: (asset: { type: 'asset', fileName: string, source: Uint8Array }) => void\n resolve?: (source: string, importer?: string, options?: { skipSelf?: boolean }) => Promise<{ id: string } | null>\n}\n\ntype WebTransformResult = { code: string, map: SourceMap | null } | null\n\ninterface WebPostcssConfig {\n plugins?: Array<{ postcssPlugin?: string }>\n [key: string]: unknown\n}\n\ninterface WebCssConfig {\n postcss?: string | WebPostcssConfig\n}\n\ninterface WebUserConfig {\n css?: {\n postcss?: string | WebPostcssConfig\n }\n}\n\ninterface WebResolvedConfig extends WebUserConfig {\n root: string\n command: string\n createResolver?: () => ResolveWebModuleId\n optimizeDeps?: {\n exclude?: string[]\n include?: string[]\n }\n}\n\ninterface WebHmrContext {\n file: string\n}\n\ninterface WebDevServer {\n middlewares: {\n use: (middleware: ReturnType<typeof createWebAssetMiddleware>) => void\n }\n}\n\ninterface WeappWebVitePlugin {\n name: string\n enforce?: 'pre' | 'post'\n config?: (this: WebPluginContext, config: WebUserConfig) => WebUserConfig | void\n configResolved?: (this: WebPluginContext, config: WebResolvedConfig) => void | Promise<void>\n configureServer?: (server: WebDevServer) => void\n buildStart?: (this: WebPluginContext) => void | Promise<void>\n resolveId?: (id: string, importer?: string) => string | null | Promise<string | null>\n load?: (id: string) => string | null | Promise<string | null>\n handleHotUpdate?: (this: WebPluginContext, ctx: WebHmrContext) => void | Promise<void>\n transform?: (\n this: WebPluginContext,\n code: string,\n id: string,\n ) => WebTransformResult | Promise<WebTransformResult>\n}\n\nfunction isTemplateFile(id: string) {\n const lower = id.toLowerCase()\n return TEMPLATE_EXTS.some(ext => lower.endsWith(ext))\n}\n\nfunction isWxsFile(id: string) {\n const lower = id.toLowerCase()\n return WXS_EXTS.some(ext => lower.endsWith(ext))\n}\n\nfunction hasWxsQuery(id: string) {\n return id.includes('?wxs') || id.includes('&wxs')\n}\n\nfunction hasQuery(id: string, query: string) {\n return id.includes(`?${query}`) || id.includes(`&${query}`)\n}\n\nfunction isUniAppDependency(id: string, includes: readonly string[]) {\n return includes.some(packageName => id === packageName || id.startsWith(`${packageName}/`))\n}\n\nfunction resolveSfcStyleSourceFilename(id: string) {\n const filename = cleanUrl(id)\n const vueSuffixIndex = filename.lastIndexOf('.vue.')\n return vueSuffixIndex >= 0\n ? filename.slice(0, vueSuffixIndex + '.vue'.length)\n : filename\n}\n\nfunction createWebCssConfig(\n config: WebUserConfig,\n wxssOptions: WeappWebPluginOptions['wxss'],\n warn?: (message: string) => void,\n): WebCssConfig | undefined {\n const postcssConfig = config.css?.postcss\n if (typeof postcssConfig === 'string') {\n warn?.('[@weapp-vite/web] css.postcss 使用配置文件路径时无法注入 WXSS 转换插件。')\n return undefined\n }\n\n const plugins = postcssConfig?.plugins ?? []\n if (plugins.some(plugin => plugin.postcssPlugin === 'weapp-vite-web-wxss')) {\n return undefined\n }\n\n return {\n postcss: {\n ...postcssConfig,\n plugins: [...plugins, createWxssPostcssPlugin(wxssOptions)],\n },\n }\n}\n\nexport function weappWebPlugin(options: WeappWebPluginOptions = {}): WeappWebVitePlugin {\n let root = process.cwd()\n let srcRoot = resolve(root, options.srcDir ?? 'src')\n let enableHmr = false\n let resolveWebModuleId: ResolveWebModuleId | undefined\n let resolveWebAutoImportTag: ResolveWebAutoImportTag | undefined\n const componentImportIdMap = new Map<string, string>()\n\n const state = createEmptyScanState()\n const wxssOptions = options.wxss\n const runtimeProvider = options.__runtimeProvider\n const hmrAcceptCode = runtimeProvider\n ? runtimeProvider.hmrAcceptCode\n : 'if (import.meta.hot) { import.meta.hot.accept() }'\n\n const resolveTemplatePath = (raw: string, importer: string) => resolveTemplatePathSync(raw, importer, srcRoot)\n const resolveWxsPath = (raw: string, importer: string) => resolveWxsPathSync(raw, importer, srcRoot)\n const resolveMetaByTemplate = (filename: string) => {\n const normalized = normalizePath(filename)\n for (const meta of state.moduleMeta.values()) {\n if (meta.templatePath && normalizePath(meta.templatePath) === normalized) {\n return meta\n }\n }\n return undefined\n }\n\n const createAutoImportTagResolver = (): ResolveWebAutoImportTag | undefined => {\n const resolvers = options.__autoImportResolvers\n if (!resolvers?.length) {\n return undefined\n }\n return async (tag, importer) => {\n for (const resolver of resolvers) {\n let matched: WebResolvedComponent | void\n if (typeof resolver === 'function') {\n matched = resolver(tag, importer)\n }\n else if (typeof resolver.resolve === 'function') {\n matched = resolver.resolve(tag, importer)\n }\n else {\n const from = resolver.components?.[tag]\n matched = from ? { name: tag, from } : undefined\n }\n if (!matched) {\n continue\n }\n const request = matched.resolvedId ?? matched.from\n const resolvedId = await resolveWebModuleId?.(request, importer)\n return {\n ...matched,\n resolvedId: resolvedId ?? matched.resolvedId,\n sourceType: matched.sourceType ?? (resolvedId?.endsWith('.vue') ? 'wevu-sfc' : 'native'),\n }\n }\n return undefined\n }\n }\n\n const scan = async (context: WebPluginContext) => {\n await scanProject({\n srcRoot,\n warn: context.warn?.bind(context),\n state,\n resolveId: resolveWebModuleId,\n resolveAutoImportTag: resolveWebAutoImportTag,\n resolveAppConfig: options.__resolveAppConfig,\n uniApp: options.__uniApp,\n })\n componentImportIdMap.clear()\n for (const component of state.scanResult.components) {\n if (component.importId) {\n componentImportIdMap.set(component.importId, component.script)\n }\n }\n }\n\n return {\n name: '@weapp-vite/web',\n enforce: 'pre',\n config(this: WebPluginContext, config: WebUserConfig) {\n const css = createWebCssConfig(config, wxssOptions, this.warn?.bind(this))\n return css ? { css } : undefined\n },\n async configResolved(this: WebPluginContext, config: WebResolvedConfig) {\n root = config.root\n srcRoot = resolve(root, options.srcDir ?? 'src')\n enableHmr = config.command === 'serve'\n resolveWebModuleId = config.createResolver?.()\n resolveWebAutoImportTag = createAutoImportTagResolver()\n await scan(this)\n const componentDependencies = await collectExternalComponentOptimizeDeps(state.scanResult.components)\n const uniAppIncludes = options.__uniApp?.include ?? []\n config.optimizeDeps ??= {}\n config.optimizeDeps.exclude = Array.from(new Set([\n ...(config.optimizeDeps.exclude ?? []),\n ...uniAppIncludes,\n ]))\n config.optimizeDeps.include = Array.from(new Set([\n ...(config.optimizeDeps.include ?? []),\n ...componentDependencies,\n ])).filter(dependency => !isUniAppDependency(dependency, uniAppIncludes))\n },\n configureServer(server: WebDevServer) {\n server.middlewares.use(createWebAssetMiddleware(srcRoot))\n },\n async buildStart(this: WebPluginContext) {\n if (!resolveWebModuleId && this.resolve) {\n resolveWebModuleId = async (source, importer) => {\n const resolved = await this.resolve?.(source, importer, { skipSelf: true })\n return resolved?.id\n }\n }\n resolveWebAutoImportTag = createAutoImportTagResolver()\n await scan(this)\n if (!enableHmr) {\n await emitWebAssets(this, srcRoot)\n }\n },\n resolveId(id: string, importer?: string) {\n if (id === '/@weapp-vite/web/entry' || id === '@weapp-vite/web/entry') {\n return ENTRY_ID\n }\n if (id === AUTO_ROUTES_ID) {\n return RESOLVED_AUTO_ROUTES_ID\n }\n if (id.startsWith(WEB_COMPONENT_PREFIX)) {\n const request = decodeURIComponent(id.slice(WEB_COMPONENT_PREFIX.length))\n const resolvedId = componentImportIdMap.get(request)\n return resolvedId ? `${cleanUrl(resolvedId)}?${WEB_COMPONENT_QUERY}` : null\n }\n if (id.startsWith('.') && importer && cleanUrl(importer).endsWith('.vue') && !extname(id)) {\n const resolvedScript = resolveFileWithExtensionsSync(resolve(dirname(cleanUrl(importer)), id), SCRIPT_EXTS)\n if (resolvedScript?.endsWith('.vue')) {\n return resolvedScript\n }\n }\n if (hasQuery(id, SFC_STYLE_QUERY)) {\n const queryIndex = id.indexOf('?')\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id\n const query = queryIndex >= 0 ? id.slice(queryIndex) : ''\n if (pathname.startsWith('.') && importer) {\n return `${resolve(dirname(cleanUrl(importer)), pathname)}${query}`\n }\n return id\n }\n return null\n },\n async load(this: WebPluginContext, id: string) {\n if (id === ENTRY_ID) {\n return generateEntryModule(state.scanResult, root, wxssOptions, options)\n }\n if (id === RESOLVED_AUTO_ROUTES_ID) {\n return generateAutoRoutesModule(state.scanResult)\n }\n if (hasQuery(id, TEMPLATE_QUERY)) {\n const filename = cleanUrl(id)\n let source = await readFile(filename, 'utf8')\n const pageMeta = resolveMetaByTemplate(filename)\n if (pageMeta?.kind === 'page' && state.scanResult.layouts.length) {\n source = wrapPageTemplate(source, state.scanResult.layouts)\n }\n const navigationConfig = state.pageNavigationMap.get(normalizePath(filename))\n const componentTags = state.templateComponentMap.get(normalizePath(filename))\n const compiled = compileWxml({\n id: filename,\n source,\n resolveTemplatePath,\n resolveWxsPath,\n navigationBar: navigationConfig ? { config: navigationConfig } : undefined,\n componentTags,\n })\n for (const dependency of compiled.dependencies) {\n this.addWatchFile?.(dependency)\n }\n for (const warning of compiled.warnings ?? []) {\n this.warn?.(warning)\n }\n return compiled.code\n }\n if (hasWxsQuery(id)) {\n const filename = cleanUrl(id)\n const source = await readFile(filename, 'utf8')\n const compiled = transformWxsToEsm(source, filename, {\n resolvePath: resolveWxsPath,\n toImportPath: (resolved, importer) => normalizePath(toRelativeImport(importer, resolved)),\n })\n for (const dependency of compiled.dependencies) {\n this.addWatchFile?.(dependency)\n }\n for (const warning of compiled.warnings ?? []) {\n this.warn?.(warning)\n }\n return compiled.code\n }\n if (hasQuery(id, STYLE_QUERY)) {\n const source = await readFile(cleanUrl(id), 'utf8')\n const { css } = transformWxssToCss(source, wxssOptions)\n return createInlineStyleModule(css)\n }\n if (id.includes(`?${SFC_TEMPLATE_QUERY}`) || id.includes(`&${SFC_TEMPLATE_QUERY}`)) {\n const filename = cleanUrl(id)\n const meta = state.moduleMeta.get(normalizePath(filename))\n if (!meta) {\n return null\n }\n const result = await ensureWebVueSfcResult({\n filename,\n meta,\n srcRoot,\n state,\n resolveId: resolveWebModuleId,\n resolveAutoImportTag: resolveWebAutoImportTag,\n uniApp: options.__uniApp,\n })\n const compiled = generateWebVueSfcTemplate(result, meta, filename, srcRoot)\n for (const dependency of compiled.dependencies) {\n this.addWatchFile?.(dependency)\n }\n for (const warning of compiled.warnings ?? []) {\n this.warn?.(warning)\n }\n return compiled.code\n }\n if (id.includes(`?${SFC_STYLE_QUERY}`) || id.includes(`&${SFC_STYLE_QUERY}`)) {\n const filename = resolveSfcStyleSourceFilename(id)\n const meta = state.moduleMeta.get(normalizePath(filename))\n if (!meta) {\n return null\n }\n const result = await ensureWebVueSfcResult({\n filename,\n meta,\n srcRoot,\n state,\n resolveId: resolveWebModuleId,\n resolveAutoImportTag: resolveWebAutoImportTag,\n uniApp: options.__uniApp,\n })\n return generateWebVueSfcStyle(result)\n }\n return null\n },\n async handleHotUpdate(this: WebPluginContext, ctx: WebHmrContext) {\n const clean = cleanUrl(ctx.file)\n if (clean.endsWith('.json') || isTemplateFile(clean) || isWxsFile(clean) || clean.endsWith('.wxss') || SCRIPT_EXTS.includes(extname(clean))) {\n await scan(this)\n }\n },\n async transform(this: WebPluginContext, code: string, id: string) {\n const clean = cleanUrl(id)\n let uniAppTransformed = false\n\n if (\n options.__uniApp\n && isUniAppCompatibilityFile(clean, srcRoot, options.__uniApp.include)\n && !clean.endsWith('.vue')\n ) {\n const transformed = transformUniAppSource(code, { filename: clean, target: 'h5' })\n if (transformed.changed) {\n code = transformed.code\n uniAppTransformed = true\n }\n }\n\n if (\n hasQuery(id, TEMPLATE_QUERY)\n || hasWxsQuery(id)\n || hasQuery(id, STYLE_QUERY)\n || hasQuery(id, SFC_TEMPLATE_QUERY)\n || hasQuery(id, SFC_STYLE_QUERY)\n ) {\n return null\n }\n\n if (clean.endsWith('.vue')) {\n const normalized = normalizePath(clean)\n const meta = state.moduleMeta.get(normalized) ?? {\n kind: 'component' as const,\n id: getStableWebComponentId(clean, srcRoot),\n scriptPath: clean,\n sourceType: 'vue-sfc' as const,\n }\n state.moduleMeta.set(normalized, meta)\n const result = await ensureWebVueSfcResult({\n filename: clean,\n meta,\n srcRoot,\n state,\n source: code,\n resolveId: resolveWebModuleId,\n resolveAutoImportTag: resolveWebAutoImportTag,\n uniApp: options.__uniApp,\n })\n return transformWebVueSfcScript({\n code: result.script!,\n filename: clean,\n meta,\n runtimeModuleId: runtimeProvider?.moduleId ?? toViteFsImport(resolveRuntimePolyfillPath()),\n styleLanguage: resolveWebVueSfcStyleLanguage(result, clean),\n enableHmr,\n hmrAcceptCode,\n })\n }\n\n if (isTemplateFile(clean)) {\n if (isHtmlEntry(clean, root)) {\n return null\n }\n const normalizedId = normalizePath(clean)\n if (state.templatePathSet.size > 0) {\n if (!isInsideDir(clean, srcRoot)) {\n return null\n }\n if (!state.templatePathSet.has(normalizedId)) {\n return null\n }\n }\n let templateSource = code\n const pageMeta = resolveMetaByTemplate(clean)\n if (pageMeta?.kind === 'page' && state.scanResult.layouts.length) {\n templateSource = wrapPageTemplate(code, state.scanResult.layouts)\n }\n const navigationConfig = state.pageNavigationMap.get(normalizedId)\n const componentTags = state.templateComponentMap.get(normalizedId)\n const { code: compiled, dependencies, warnings } = compileWxml({\n id: clean,\n source: templateSource,\n resolveTemplatePath,\n resolveWxsPath,\n navigationBar: navigationConfig ? { config: navigationConfig } : undefined,\n componentTags,\n })\n const addWatchFile = this.addWatchFile\n if (dependencies.length > 0 && addWatchFile) {\n for (const dep of dependencies) {\n addWatchFile.call(this, dep)\n }\n }\n const warn = this.warn\n if (warnings?.length && warn) {\n for (const warning of warnings) {\n warn.call(this, warning)\n }\n }\n return { code: compiled, map: null }\n }\n\n if (isWxsFile(clean) || hasWxsQuery(id)) {\n const { code: compiled, dependencies, warnings } = transformWxsToEsm(code, clean, {\n resolvePath: resolveWxsPath,\n toImportPath: (resolved, importer) => normalizePath(toRelativeImport(importer, resolved)),\n })\n const addWatchFile = this.addWatchFile\n if (dependencies.length > 0 && addWatchFile) {\n for (const dep of dependencies) {\n addWatchFile.call(this, dep)\n }\n }\n const warn = this.warn\n if (warnings?.length && warn) {\n for (const warning of warnings) {\n warn.call(this, warning)\n }\n }\n return { code: compiled, map: null }\n }\n\n if (TRANSFORM_STYLE_EXTS.some(ext => clean.endsWith(ext))) {\n const { css } = transformWxssToCss(code, wxssOptions)\n return {\n code: createInlineStyleModule(css),\n map: null,\n }\n }\n\n if (STYLE_EXTS.some(ext => clean.endsWith(ext)) && !clean.endsWith('.wxss')) {\n const { css } = transformWxssToCss(code, wxssOptions)\n return { code: css, map: null }\n }\n\n if (!SCRIPT_EXTS.some(ext => clean.endsWith(ext))) {\n return uniAppTransformed ? { code, map: null } : null\n }\n if (clean.includes('node_modules') && !hasQuery(id, WEB_COMPONENT_QUERY)) {\n return options.__uniApp && isUniAppCompatibilityFile(clean, srcRoot, options.__uniApp.include)\n ? { code, map: null }\n : null\n }\n\n const meta = state.moduleMeta.get(normalizePath(clean))\n if (!meta) {\n return null\n }\n\n return transformScriptModule({\n code,\n cleanId: clean,\n meta,\n enableHmr,\n runtimeModuleId: runtimeProvider?.moduleId,\n hmrAcceptCode,\n })\n },\n }\n}\n\nexport type { WeappWebPluginOptions } from './types'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmFA,SAAS,eAAe,IAAY;CAClC,MAAM,QAAQ,GAAG,YAAY;CAC7B,OAAO,cAAc,MAAK,QAAO,MAAM,SAAS,GAAG,CAAC;AACtD;AAEA,SAAS,UAAU,IAAY;CA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1
|
+
//#region src/plugin/layout.ts
|
|
2
|
+
function collectLayoutPropKeys(layouts) {
|
|
3
|
+
const keys = /* @__PURE__ */ new Set();
|
|
4
|
+
for (const layout of layouts) {
|
|
5
|
+
if (!layout.template) continue;
|
|
6
|
+
const matches = layout.template.matchAll(/\{\{\s*([a-z_$][\w$]*)/gi);
|
|
7
|
+
for (const match of matches) if (match[1] && match[1] !== "item" && match[1] !== "index") keys.add(match[1]);
|
|
8
|
+
}
|
|
9
|
+
return [...keys];
|
|
10
|
+
}
|
|
11
|
+
function wrapPageTemplate(source, layouts) {
|
|
12
|
+
if (!layouts.length) return source;
|
|
13
|
+
const propKeys = collectLayoutPropKeys(layouts);
|
|
14
|
+
return `${layouts.map((layout, index) => {
|
|
15
|
+
const condition = index === 0 ? `!__wv_page_layout_name || __wv_page_layout_name === '${layout.name}'` : `__wv_page_layout_name === '${layout.name}'`;
|
|
16
|
+
const attrs = propKeys.map((key) => `${key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)}="{{(__wv_page_layout_props&&__wv_page_layout_props.${key})}}"`).join(" ");
|
|
17
|
+
const open = attrs ? `<${layout.tag} ${attrs}>` : `<${layout.tag}>`;
|
|
18
|
+
return `<block ${index === 0 ? "wx:if" : "wx:elif"}="{{${condition}}}">${open}${source}</${layout.tag}></block>`;
|
|
19
|
+
}).join("")}<block wx:else>${source}</block>`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { wrapPageTemplate };
|
|
24
|
+
//# sourceMappingURL=layout.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.mjs","names":[],"sources":["../../src/plugin/layout.ts"],"sourcesContent":["import type { LayoutEntry } from './types'\n\nfunction collectLayoutPropKeys(layouts: LayoutEntry[]) {\n const keys = new Set<string>()\n for (const layout of layouts) {\n if (!layout.template) {\n continue\n }\n const matches = layout.template.matchAll(/\\{\\{\\s*([a-z_$][\\w$]*)/gi)\n for (const match of matches) {\n if (match[1] && match[1] !== 'item' && match[1] !== 'index') {\n keys.add(match[1])\n }\n }\n }\n return [...keys]\n}\n\nexport function wrapPageTemplate(source: string, layouts: LayoutEntry[]) {\n if (!layouts.length) {\n return source\n }\n const propKeys = collectLayoutPropKeys(layouts)\n const branches = layouts.map((layout, index) => {\n const condition = index === 0\n ? `!__wv_page_layout_name || __wv_page_layout_name === '${layout.name}'`\n : `__wv_page_layout_name === '${layout.name}'`\n const attrs = propKeys.map(key => `${key.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)}=\"{{(__wv_page_layout_props&&__wv_page_layout_props.${key})}}\"`).join(' ')\n const open = attrs ? `<${layout.tag} ${attrs}>` : `<${layout.tag}>`\n const directive = index === 0 ? 'wx:if' : 'wx:elif'\n return `<block ${directive}=\"{{${condition}}}\">${open}${source}</${layout.tag}></block>`\n })\n return `${branches.join('')}<block wx:else>${source}</block>`\n}\n"],"mappings":";AAEA,SAAS,sBAAsB,SAAwB;CACrD,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,CAAC,OAAO,UACV;EAEF,MAAM,UAAU,OAAO,SAAS,SAAS,0BAA0B;EACnE,KAAK,MAAM,SAAS,SAClB,IAAI,MAAM,MAAM,MAAM,OAAO,UAAU,MAAM,OAAO,SAClD,KAAK,IAAI,MAAM,EAAE;CAGvB;CACA,OAAO,CAAC,GAAG,IAAI;AACjB;AAEA,SAAgB,iBAAiB,QAAgB,SAAwB;CACvE,IAAI,CAAC,QAAQ,QACX,OAAO;CAET,MAAM,WAAW,sBAAsB,OAAO;CAU9C,OAAO,GATU,QAAQ,KAAK,QAAQ,UAAU;EAC9C,MAAM,YAAY,UAAU,IACxB,wDAAwD,OAAO,KAAK,KACpE,8BAA8B,OAAO,KAAK;EAC9C,MAAM,QAAQ,SAAS,KAAI,QAAO,GAAG,IAAI,QAAQ,WAAU,UAAS,IAAI,MAAM,YAAY,GAAG,EAAE,sDAAsD,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG;EACxK,MAAM,OAAO,QAAQ,IAAI,OAAO,IAAI,GAAG,MAAM,KAAK,IAAI,OAAO,IAAI;EAEjE,OAAO,UADW,UAAU,IAAI,UAAU,UACf,MAAM,UAAU,MAAM,OAAO,OAAO,IAAI,OAAO,IAAI;CAChF,CACiB,CAAC,CAAC,KAAK,EAAE,EAAE,iBAAiB,OAAO;AACtD"}
|
package/dist/plugin/path.mjs
CHANGED
|
@@ -24,7 +24,8 @@ function toPosixId(id) {
|
|
|
24
24
|
return normalize(id).split("\\").join("/");
|
|
25
25
|
}
|
|
26
26
|
function toRelativeImport(from, target) {
|
|
27
|
-
const
|
|
27
|
+
const fromDir = dirname(from);
|
|
28
|
+
const rel = relative(fromDir, target);
|
|
28
29
|
if (!rel || rel.startsWith(".")) return normalizePath(rel || `./${posix.basename(target)}`);
|
|
29
30
|
return `./${normalizePath(rel)}`;
|
|
30
31
|
}
|
|
@@ -35,6 +36,9 @@ function appendInlineQuery(id) {
|
|
|
35
36
|
}
|
|
36
37
|
return `${id}?inline`;
|
|
37
38
|
}
|
|
39
|
+
function appendQuery(id, query) {
|
|
40
|
+
return `${id}${id.includes("?") ? "&" : "?"}${query}`;
|
|
41
|
+
}
|
|
38
42
|
function relativeModuleId(root, absPath) {
|
|
39
43
|
return `/${normalizePath(relative(root, absPath))}`;
|
|
40
44
|
}
|
|
@@ -81,5 +85,5 @@ function resolveWxsPathSync(raw, importer, srcRoot) {
|
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
//#endregion
|
|
84
|
-
export { appendInlineQuery, cleanUrl, isHtmlEntry, isInsideDir, normalizePath, relativeModuleId, resolveFileWithExtensionsSync, resolveImportBase, resolveRuntimePolyfillPath, resolveTemplatePathSync, resolveWxsPathSync, toPosixId, toRelativeImport, toViteFsImport };
|
|
88
|
+
export { appendInlineQuery, appendQuery, cleanUrl, isHtmlEntry, isInsideDir, normalizePath, relativeModuleId, resolveFileWithExtensionsSync, resolveImportBase, resolveRuntimePolyfillPath, resolveTemplatePathSync, resolveWxsPathSync, toPosixId, toRelativeImport, toViteFsImport };
|
|
85
89
|
//# sourceMappingURL=path.mjs.map
|
package/dist/plugin/path.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.mjs","names":[],"sources":["../../src/plugin/path.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { dirname, extname, normalize, posix, relative, resolve } from 'pathe'\n\nimport { TEMPLATE_EXTS, WXS_RESOLVE_EXTS } from './constants'\n\nexport function cleanUrl(url: string) {\n const queryIndex = url.indexOf('?')\n if (queryIndex >= 0) {\n return url.slice(0, queryIndex)\n }\n return url\n}\n\nexport function normalizePath(p: string) {\n return posix.normalize(p.split('\\\\').join('/'))\n}\n\nexport function isInsideDir(filePath: string, dir: string) {\n const rel = relative(dir, filePath)\n return rel === '' || (!rel.startsWith('..') && !posix.isAbsolute(rel))\n}\n\nexport function isHtmlEntry(filePath: string, root: string) {\n if (!filePath.toLowerCase().endsWith('.html')) {\n return false\n }\n return normalizePath(filePath) === normalizePath(resolve(root, 'index.html'))\n}\n\nexport function toPosixId(id: string) {\n return normalize(id).split('\\\\').join('/')\n}\n\nexport function toRelativeImport(from: string, target: string) {\n const fromDir = dirname(from)\n const rel = relative(fromDir, target)\n if (!rel || rel.startsWith('.')) {\n return normalizePath(rel || `./${posix.basename(target)}`)\n }\n return `./${normalizePath(rel)}`\n}\n\nexport function appendInlineQuery(id: string) {\n if (id.includes('?')) {\n if (id.includes('?inline') || id.includes('&inline')) {\n return id\n }\n return `${id}&inline`\n }\n return `${id}?inline`\n}\n\nexport function relativeModuleId(root: string, absPath: string) {\n const rel = relative(root, absPath)\n return `/${normalizePath(rel)}`\n}\n\nexport function toViteFsImport(absPath: string) {\n const normalized = normalizePath(absPath)\n return normalized.startsWith('/')\n ? `/@fs${normalized}`\n : `/@fs/${normalized}`\n}\n\nexport function resolveRuntimePolyfillPath() {\n const currentDir = dirname(fileURLToPath(import.meta.url))\n const candidates = [\n resolve(currentDir, '../runtime/index.mjs'),\n resolve(currentDir, './runtime/index.mjs'),\n resolve(currentDir, '../runtime/polyfill.ts'),\n resolve(currentDir, '../runtime/index.ts'),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return candidate\n }\n }\n\n throw new Error('[@weapp-vite/web] Failed to resolve runtime polyfill path.')\n}\n\nexport function resolveImportBase(raw: string, importer: string, srcRoot: string) {\n if (!raw) {\n return undefined\n }\n if (raw.startsWith('.')) {\n return resolve(dirname(importer), raw)\n }\n if (raw.startsWith('/')) {\n return resolve(srcRoot, raw.slice(1))\n }\n return resolve(srcRoot, raw)\n}\n\nexport function resolveFileWithExtensionsSync(basePath: string, extensions: string[]) {\n if (extname(basePath) && existsSync(basePath)) {\n return basePath\n }\n for (const ext of extensions) {\n const candidate = `${basePath}${ext}`\n if (existsSync(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport function resolveTemplatePathSync(raw: string, importer: string, srcRoot: string) {\n const base = resolveImportBase(raw, importer, srcRoot)\n if (!base) {\n return undefined\n }\n return resolveFileWithExtensionsSync(base, TEMPLATE_EXTS)\n}\n\nexport function resolveWxsPathSync(raw: string, importer: string, srcRoot: string) {\n if (!raw) {\n return undefined\n }\n let base: string | undefined\n if (raw.startsWith('.')) {\n base = resolve(dirname(importer), raw)\n }\n else if (raw.startsWith('/')) {\n base = resolve(srcRoot, raw.slice(1))\n }\n else {\n return undefined\n }\n return resolveFileWithExtensionsSync(base, WXS_RESOLVE_EXTS)\n}\n"],"mappings":";;;;;;AAMA,SAAgB,SAAS,KAAa;CACpC,MAAM,aAAa,IAAI,QAAQ,GAAG;CAClC,IAAI,cAAc,GAChB,OAAO,IAAI,MAAM,GAAG,UAAU;CAEhC,OAAO;AACT;AAEA,SAAgB,cAAc,GAAW;CACvC,OAAO,MAAM,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC;AAChD;AAEA,SAAgB,YAAY,UAAkB,KAAa;CACzD,MAAM,MAAM,SAAS,KAAK,QAAQ;CAClC,OAAO,QAAQ,MAAO,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,WAAW,GAAG;AACtE;AAEA,SAAgB,YAAY,UAAkB,MAAc;CAC1D,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC,SAAS,OAAO,GAC1C,OAAO;CAET,OAAO,cAAc,QAAQ,MAAM,cAAc,QAAQ,MAAM,YAAY,CAAC;AAC9E;AAEA,SAAgB,UAAU,IAAY;CACpC,OAAO,UAAU,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;AAC3C;AAEA,SAAgB,iBAAiB,MAAc,QAAgB;
|
|
1
|
+
{"version":3,"file":"path.mjs","names":[],"sources":["../../src/plugin/path.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { dirname, extname, normalize, posix, relative, resolve } from 'pathe'\n\nimport { TEMPLATE_EXTS, WXS_RESOLVE_EXTS } from './constants'\n\nexport function cleanUrl(url: string) {\n const queryIndex = url.indexOf('?')\n if (queryIndex >= 0) {\n return url.slice(0, queryIndex)\n }\n return url\n}\n\nexport function normalizePath(p: string) {\n return posix.normalize(p.split('\\\\').join('/'))\n}\n\nexport function isInsideDir(filePath: string, dir: string) {\n const rel = relative(dir, filePath)\n return rel === '' || (!rel.startsWith('..') && !posix.isAbsolute(rel))\n}\n\nexport function isHtmlEntry(filePath: string, root: string) {\n if (!filePath.toLowerCase().endsWith('.html')) {\n return false\n }\n return normalizePath(filePath) === normalizePath(resolve(root, 'index.html'))\n}\n\nexport function toPosixId(id: string) {\n return normalize(id).split('\\\\').join('/')\n}\n\nexport function toRelativeImport(from: string, target: string) {\n const fromDir = dirname(from)\n const rel = relative(fromDir, target)\n if (!rel || rel.startsWith('.')) {\n return normalizePath(rel || `./${posix.basename(target)}`)\n }\n return `./${normalizePath(rel)}`\n}\n\nexport function appendInlineQuery(id: string) {\n if (id.includes('?')) {\n if (id.includes('?inline') || id.includes('&inline')) {\n return id\n }\n return `${id}&inline`\n }\n return `${id}?inline`\n}\n\nexport function appendQuery(id: string, query: string) {\n return `${id}${id.includes('?') ? '&' : '?'}${query}`\n}\n\nexport function relativeModuleId(root: string, absPath: string) {\n const rel = relative(root, absPath)\n return `/${normalizePath(rel)}`\n}\n\nexport function toViteFsImport(absPath: string) {\n const normalized = normalizePath(absPath)\n return normalized.startsWith('/')\n ? `/@fs${normalized}`\n : `/@fs/${normalized}`\n}\n\nexport function resolveRuntimePolyfillPath() {\n const currentDir = dirname(fileURLToPath(import.meta.url))\n const candidates = [\n resolve(currentDir, '../runtime/index.mjs'),\n resolve(currentDir, './runtime/index.mjs'),\n resolve(currentDir, '../runtime/polyfill.ts'),\n resolve(currentDir, '../runtime/index.ts'),\n ]\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) {\n return candidate\n }\n }\n\n throw new Error('[@weapp-vite/web] Failed to resolve runtime polyfill path.')\n}\n\nexport function resolveImportBase(raw: string, importer: string, srcRoot: string) {\n if (!raw) {\n return undefined\n }\n if (raw.startsWith('.')) {\n return resolve(dirname(importer), raw)\n }\n if (raw.startsWith('/')) {\n return resolve(srcRoot, raw.slice(1))\n }\n return resolve(srcRoot, raw)\n}\n\nexport function resolveFileWithExtensionsSync(basePath: string, extensions: string[]) {\n if (extname(basePath) && existsSync(basePath)) {\n return basePath\n }\n for (const ext of extensions) {\n const candidate = `${basePath}${ext}`\n if (existsSync(candidate)) {\n return candidate\n }\n }\n return undefined\n}\n\nexport function resolveTemplatePathSync(raw: string, importer: string, srcRoot: string) {\n const base = resolveImportBase(raw, importer, srcRoot)\n if (!base) {\n return undefined\n }\n return resolveFileWithExtensionsSync(base, TEMPLATE_EXTS)\n}\n\nexport function resolveWxsPathSync(raw: string, importer: string, srcRoot: string) {\n if (!raw) {\n return undefined\n }\n let base: string | undefined\n if (raw.startsWith('.')) {\n base = resolve(dirname(importer), raw)\n }\n else if (raw.startsWith('/')) {\n base = resolve(srcRoot, raw.slice(1))\n }\n else {\n return undefined\n }\n return resolveFileWithExtensionsSync(base, WXS_RESOLVE_EXTS)\n}\n"],"mappings":";;;;;;AAMA,SAAgB,SAAS,KAAa;CACpC,MAAM,aAAa,IAAI,QAAQ,GAAG;CAClC,IAAI,cAAc,GAChB,OAAO,IAAI,MAAM,GAAG,UAAU;CAEhC,OAAO;AACT;AAEA,SAAgB,cAAc,GAAW;CACvC,OAAO,MAAM,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC;AAChD;AAEA,SAAgB,YAAY,UAAkB,KAAa;CACzD,MAAM,MAAM,SAAS,KAAK,QAAQ;CAClC,OAAO,QAAQ,MAAO,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,MAAM,WAAW,GAAG;AACtE;AAEA,SAAgB,YAAY,UAAkB,MAAc;CAC1D,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC,SAAS,OAAO,GAC1C,OAAO;CAET,OAAO,cAAc,QAAQ,MAAM,cAAc,QAAQ,MAAM,YAAY,CAAC;AAC9E;AAEA,SAAgB,UAAU,IAAY;CACpC,OAAO,UAAU,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;AAC3C;AAEA,SAAgB,iBAAiB,MAAc,QAAgB;CAC7D,MAAM,UAAU,QAAQ,IAAI;CAC5B,MAAM,MAAM,SAAS,SAAS,MAAM;CACpC,IAAI,CAAC,OAAO,IAAI,WAAW,GAAG,GAC5B,OAAO,cAAc,OAAO,KAAK,MAAM,SAAS,MAAM,GAAG;CAE3D,OAAO,KAAK,cAAc,GAAG;AAC/B;AAEA,SAAgB,kBAAkB,IAAY;CAC5C,IAAI,GAAG,SAAS,GAAG,GAAG;EACpB,IAAI,GAAG,SAAS,SAAS,KAAK,GAAG,SAAS,SAAS,GACjD,OAAO;EAET,OAAO,GAAG,GAAG;CACf;CACA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