vite-plugin-taro 0.0.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/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/public/components.d.ts +1 -0
- package/dist/public/components.js +1 -0
- package/dist/public/taro.d.ts +2 -0
- package/dist/public/taro.js +10 -0
- package/dist/public/taro.js.map +1 -0
- package/dist/shim/h5.d.ts +3 -0
- package/dist/shim/h5.js +6 -0
- package/dist/shim/wx.d.ts +3 -0
- package/dist/shim/wx.js +5 -0
- package/dist/vite/constants.d.ts +2 -0
- package/dist/vite/plugins.d.ts +8 -0
- package/dist/vite/tailwindcss.d.ts +3 -0
- package/dist/vite/targets/h5.d.ts +31 -0
- package/dist/vite/targets/wx.d.ts +74 -0
- package/dist/vite/taro.d.ts +7 -0
- package/dist/vite/types.d.ts +38 -0
- package/dist/vite/utils.d.ts +22 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +851 -0
- package/dist/vite.js.map +1 -0
- package/package.json +97 -0
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/vite/utils.ts","../src/vite/plugins.ts","../src/vite/tailwindcss.ts","../src/vite/constants.ts","../src/vite/targets/h5.ts","../src/vite/targets/wx.ts","../src/vite/taro.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Derives a page component import from a Taro-style page path.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L660-L668\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/utils/app.ts#L74-L90\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-loader/src/h5.ts#L12-L21\n */\nexport function createPageComponentImport(pagePath: string): string {\n return toImportPath(`src/${pagePath}.tsx`)\n}\n\n/**\n * Converts a local file path into an absolute ESM import path for Vite.\n */\nexport function toImportPath(filePath: string): string {\n return path.resolve(filePath)\n}\n\n/**\n * Removes Rollup/Vite's internal virtual-module prefix before ID comparisons.\n */\nexport function stripVirtualPrefix(id: string): string {\n return id.startsWith('\\0') ? id.slice(1) : id\n}\n\n/**\n * Uses Taro-style slash normalization, plus Vite query-string stripping for module IDs.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-helper/src/utils.ts#L32-L34\n */\nexport function normalizeModuleId(id: string): string {\n return id.replace(/\\\\/g, '/').replace(/\\?.*$/, '')\n}\n","import type { Plugin } from 'vite'\nimport type { TaroBuildContext, TaroTarget } from './types.ts'\nimport { normalizeModuleId } from './utils.ts'\n\n/**\n * Applies Taro-style conditional compilation comments before Vite parses source files.\n *\n * Mirrors Taro's CSS #ifdef/#ifndef handling, generalized before Vite parses code.\n */\nexport function createTaroConditionalDirectivePlugin(context: TaroBuildContext): Plugin {\n const target = context.target\n return {\n name: 'vite-plugin-taro-conditional-directives',\n enforce: 'pre',\n transform(code, id) {\n if (!isConditionalDirectiveSource(id) || !code.includes('#if')) return\n return { code: transformConditionalDirectives(code, target), map: null }\n }\n }\n}\n\n/**\n * Filters files where Taro's conditional comments are meaningful.\n *\n * vite-plugin-taro-only: source filter for vite-plugin-taro's generalized conditional-directive transform.\n */\nfunction isConditionalDirectiveSource(id: string): boolean {\n const normalizedId = normalizeModuleId(id)\n if (normalizedId.includes('/node_modules/')) return false\n return /\\.(?:[cm]?[jt]sx?|css|s[ac]ss|less|styl)(?:\\?|$)/.test(normalizedId)\n}\n\ntype ConditionalDirectiveName = 'ifdef' | 'ifndef' | 'if' | 'elif' | 'else' | 'endif'\n\ntype ConditionalDirective = {\n name: ConditionalDirectiveName\n expression: string\n}\n\ntype ConditionalDirectiveFrame = {\n parentActive: boolean\n active: boolean\n matched: boolean\n}\n\n/**\n * Removes inactive blocks guarded by Taro conditional comments.\n *\n * Mirrors Taro's CSS #ifdef/#ifndef handling.\n */\nfunction transformConditionalDirectives(code: string, target: TaroTarget): string {\n const lines = code.match(/[^\\n]*(?:\\n|$)/g) ?? []\n const frames: ConditionalDirectiveFrame[] = []\n let transformed = ''\n\n for (const line of lines) {\n if (!line) continue\n const directive = parseConditionalDirective(line)\n const lineEnding = getLineEnding(line)\n if (directive) {\n updateConditionalDirectiveFrames(frames, directive, target)\n transformed += lineEnding\n continue\n }\n transformed += isDirectiveStackActive(frames) ? line : lineEnding\n }\n\n return transformed\n}\n\n/**\n * Parses one Taro conditional compilation directive from a comment-only line.\n *\n * Mirrors Taro's CSS comment-token handling.\n */\nfunction parseConditionalDirective(line: string): ConditionalDirective | undefined {\n const match = line.match(/^\\s*(?:(?:\\/\\/)|(?:\\/\\*))\\s*#(ifdef|ifndef|if|elif|else|endif)\\b([^*\\r\\n]*)/)\n if (!match) return\n const name = toConditionalDirectiveName(match[1])\n if (!name) return\n return {\n name,\n expression: match[2]?.replace(/\\*\\/$/, '').trim() ?? ''\n }\n}\n\n/**\n * Converts a regex capture into a supported directive name.\n *\n * Mirrors Taro's CSS #ifdef/#ifndef/#endif token handling.\n */\nfunction toConditionalDirectiveName(value: string): ConditionalDirectiveName | undefined {\n if (\n value === 'ifdef' ||\n value === 'ifndef' ||\n value === 'if' ||\n value === 'elif' ||\n value === 'else' ||\n value === 'endif'\n ) {\n return value\n }\n}\n\n/**\n * Updates the active conditional stack using Taro-style #ifdef/#ifndef/#else/#endif semantics.\n *\n * vite-plugin-taro-only: stack-based #if/#elif/#else support has no Taro webpack counterpart.\n */\nfunction updateConditionalDirectiveFrames(\n frames: ConditionalDirectiveFrame[],\n directive: ConditionalDirective,\n target: TaroTarget\n): void {\n if (directive.name === 'ifdef' || directive.name === 'ifndef' || directive.name === 'if') {\n const conditionMatched = evaluateConditionalDirective(directive, target)\n const parentActive = isDirectiveStackActive(frames)\n frames.push({ parentActive, active: parentActive && conditionMatched, matched: conditionMatched })\n return\n }\n\n const currentFrame = frames.at(-1)\n if (!currentFrame) return\n\n if (directive.name === 'elif') {\n if (currentFrame.matched) {\n currentFrame.active = false\n return\n }\n const conditionMatched = evaluateConditionalDirective(directive, target)\n currentFrame.active = currentFrame.parentActive && conditionMatched\n currentFrame.matched = conditionMatched\n return\n }\n\n if (directive.name === 'else') {\n currentFrame.active = currentFrame.parentActive && !currentFrame.matched\n currentFrame.matched = true\n return\n }\n\n if (directive.name === 'endif') frames.pop()\n}\n\n/**\n * Evaluates the small expression subset used by Taro conditional comments.\n *\n * Mirrors Taro's simple CSS platform membership checks.\n */\nfunction evaluateConditionalDirective(directive: ConditionalDirective, target: TaroTarget): boolean {\n if (directive.name === 'ifndef') return !matchesDirectiveTarget(directive.expression, target)\n if (directive.name === 'ifdef') return matchesDirectiveTarget(directive.expression, target)\n return evaluateConditionalExpression(directive.expression, target)\n}\n\n/**\n * Supports simple #if expressions with !, &&, and || over vite-plugin-taro target tokens.\n *\n * vite-plugin-taro-only: #if expressions with && and || have no Taro webpack counterpart.\n */\nfunction evaluateConditionalExpression(expression: string, target: TaroTarget): boolean {\n const orTerms = expression.split('||')\n return orTerms.some((term) =>\n term\n .split('&&')\n .map((factor) => factor.trim())\n .filter(Boolean)\n .every((factor) => evaluateConditionalFactor(factor, target))\n )\n}\n\n/**\n * Evaluates one vite-plugin-taro target token, optionally negated.\n *\n * vite-plugin-taro-only: negated #if factors have no Taro webpack counterpart.\n */\nfunction evaluateConditionalFactor(factor: string, target: TaroTarget): boolean {\n let token = factor.replace(/[()]/g, '').trim()\n let negated = false\n while (token.startsWith('!')) {\n negated = !negated\n token = token.slice(1).trim()\n }\n const matched = matchesDirectiveTarget(token, target)\n return negated ? !matched : matched\n}\n\n/**\n * Checks whether a directive target list includes the current vite-plugin-taro target.\n *\n * Mirrors Taro's simple CSS platform membership checks.\n */\nfunction matchesDirectiveTarget(expression: string, target: TaroTarget): boolean {\n const tokens = expression\n .split(/[\\s,|&()!]+/)\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean)\n return tokens.includes(target)\n}\n\n/**\n * Preserves source line counts when conditional blocks are stripped.\n *\n * vite-plugin-taro-only: preserves Vite source-map line counts while stripping conditional blocks.\n */\nfunction getLineEnding(line: string): string {\n const match = line.match(/\\r?\\n$/)\n return match?.[0] ?? ''\n}\n\n/**\n * Returns whether all active nested conditional frames include the current line.\n *\n * vite-plugin-taro-only: stack activity helper for generalized conditional directives.\n */\nfunction isDirectiveStackActive(frames: ConditionalDirectiveFrame[]): boolean {\n return frames.every((frame) => frame.active)\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport type { PluginOption } from 'vite'\nimport { WeappTailwindcss } from 'weapp-tailwindcss/vite'\nimport type { TaroBuildContext } from './types.ts'\n\nfunction getProjectRoot(): string {\n return process.cwd()\n}\n\nfunction getAppCssEntry(projectRoot: string): string {\n return path.resolve(projectRoot, 'src/app.css')\n}\n\nexport function createTailwindcssPlugins(context: TaroBuildContext): PluginOption[] {\n const projectRoot = getProjectRoot()\n const appCssEntry = getAppCssEntry(projectRoot)\n\n const plugins = WeappTailwindcss({\n appType: 'taro',\n generator: {\n target: context.target === 'h5' ? 'web' : 'weapp'\n },\n tailwindcssBasedir: projectRoot,\n cssEntries: [appCssEntry],\n tailwindcss: {\n version: 4,\n packageName: 'tailwindcss'\n },\n cssCalc: false,\n // skyline does not support -webkit prefix.\n autoprefixer: context.target === 'h5',\n postcssOptions: {\n // Tailwind v4 emits legacy :before/:after selectors; skyline requires ::before/::after.\n plugins: [createWechatPseudoElementPlugin()]\n },\n rem2rpx: true,\n px2rpx: true\n })\n\n return plugins ?? []\n}\n\nfunction createWechatPseudoElementPlugin() {\n const legacyPseudoElementPattern = /(?<!:):(before|after)\\b/g\n\n return {\n postcssPlugin: 'vite-plugin-taro-wechat-pseudo-elements',\n Rule(rule: { selector: string }) {\n rule.selector = rule.selector.replace(legacyPseudoElementPattern, '::$1')\n }\n }\n}\n","import { createRequire } from 'node:module'\n\nexport const isProd = process.env.NODE_ENV === 'production'\n\nexport const nodeRequire = createRequire(import.meta.url)\n","import babel from '@rolldown/plugin-babel'\nimport react from '@vitejs/plugin-react'\nimport type { HtmlTagDescriptor, PluginOption, UserConfig } from 'vite'\nimport { isProd, nodeRequire } from '../constants.ts'\nimport type { JsonObject, TaroBuildContext, TaroPageOption } from '../types.ts'\nimport { createPageComponentImport } from '../utils.ts'\n\nconst virtualH5Id = 'virtual:vite-plugin-taro/h5'\nconst pluginTaroImport = 'vite-plugin-taro/taro'\n\n/**\n * Checks whether an id belongs to an H5 virtual module.\n */\nexport function isH5VirtualModuleId(id: string): boolean {\n return id === virtualH5Id\n}\n\n/**\n * Loads generated source for H5 virtual modules.\n */\nexport function loadH5VirtualModule(cleanId: string, context: TaroBuildContext): string | undefined {\n if (cleanId !== virtualH5Id) return\n return createWebEntry(context)\n}\n\n/**\n * Configures the Vite pieces needed for Taro H5 resolve/runtime behavior.\n */\nexport function createH5ViteConfig(): UserConfig {\n return {\n define: createH5TaroDefines(),\n resolve: {\n mainFields: ['main:h5', 'browser', 'module', 'jsnext:main', 'jsnext'],\n alias: [\n // H5 React code must use Taro's React component wrappers, not the raw custom-element entry.\n { find: /^@tarojs\\/components$/, replacement: nodeRequire.resolve('@tarojs/components/lib/react') },\n // Taro's H5 router/components deep-import this custom-element loader; make it resolvable under pnpm.\n {\n find: /^@tarojs\\/components\\/dist\\/components$/,\n replacement: nodeRequire.resolve('@tarojs/components/dist/components')\n },\n // H5 APIs are exported from the platform API barrel; the generic @tarojs/taro root is native-oriented.\n {\n find: /^@tarojs\\/taro$/,\n replacement: nodeRequire.resolve('@tarojs/plugin-platform-h5/dist/runtime/apis')\n }\n ]\n },\n build: {\n target: 'es2018',\n minify: isProd\n }\n }\n}\n\n/**\n * Creates H5-only support plugins used before the target emitter runs.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-platform-h5/src/program.ts#L219-L249\n */\nexport function createH5SupportPlugins(): PluginOption[] {\n return [\n ...react(),\n // Mirrors Taro H5: rewrite default Taro.xxx calls from vite-plugin-taro/taro to named H5 API imports.\n babel({\n plugins: [\n [\n nodeRequire.resolve('babel-plugin-transform-taroapi'),\n {\n packageName: pluginTaroImport,\n definition: nodeRequire(nodeRequire.resolve('@tarojs/plugin-platform-h5/dist/definition.json'))\n }\n ]\n ]\n })\n ]\n}\n\n/**\n * Creates compile-time constants expected by Taro's Web runtime packages.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/H5WebpackPlugin.ts#L51-L69\n */\nfunction createH5TaroDefines(): Record<string, string> {\n return {\n 'process.env.FRAMEWORK': JSON.stringify('react'),\n 'process.env.SUPPORT_TARO_POLYFILL': JSON.stringify('disabled'),\n 'process.env.TARO_ENV': JSON.stringify('h5'),\n 'process.env.TARO_PLATFORM': JSON.stringify('web'),\n IS_H5: 'true',\n IS_WEAPP: 'false',\n 'process.env.SUPPORT_DINGTALK_NAVIGATE': JSON.stringify('disabled'),\n DEPRECATED_ADAPTER_COMPONENT: 'false'\n }\n}\n\n/**\n * Injects vite-plugin-taro's generated Web entry into Vite's HTML shell.\n */\nexport function createWebIndexHtmlTags(context: TaroBuildContext): HtmlTagDescriptor[] | undefined {\n if (context.target !== 'h5') return\n\n const tags: HtmlTagDescriptor[] = []\n tags.push({\n tag: 'script',\n attrs: { type: 'module' },\n children: `import '${virtualH5Id}'`,\n injectTo: 'body'\n })\n return tags\n}\n\n/**\n * Builds the generated Web entry around Taro's official Web router/runtime APIs.\n * vite-plugin-taro omits Taro's generated pxTransform initialization because styles are handled by Tailwind.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-loader/src/h5.ts#L120-L150\n */\nexport function createWebEntry(context: TaroBuildContext): string {\n const webAppConfigCode = JSON.stringify(createWebAppConfig(context.appConfig))\n const webRoutesConfigCode = createWebRoutesConfig(context.pages)\n\n return `import {\n createHashHistory,\n createReactApp,\n createRouter,\n handleAppMount,\n window\n} from 'vite-plugin-taro/shim/h5'\nimport React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport AppComponent from '${context.appComponentImport}'\n\nconst config = window.__taroAppConfig = ${webAppConfigCode}\nconfig.routes = ${webRoutesConfigCode}\nconst app = createReactApp(AppComponent, React, ReactDOM, config)\nconst history = createHashHistory({ window })\nhandleAppMount(config, history)\ncreateRouter(history, app, config, React)\n`\n}\n\n/**\n * Creates the H5 app config consumed by Taro's Web router.\n * Taro's H5 runtime expects `config.router` to exist, even when it is an empty object.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/H5Plugin.ts#L49-L53\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/H5Plugin.ts#L133-L138\n */\nfunction createWebAppConfig(sharedAppConfig: JsonObject): JsonObject {\n return {\n router: {},\n ...sharedAppConfig\n }\n}\n\n/**\n * Creates Web route records in the same shape as Taro's H5 loader.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-loader/src/h5.ts#L12-L21\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-loader/src/h5.ts#L108-L114\n */\nfunction createWebRoutesConfig(webPages: TaroPageOption[]): string {\n const webRoutes = webPages.map((page) =>\n [\n 'Object.assign({',\n ` path: ${JSON.stringify(page.path)},`,\n ' load: async function(context, params) {',\n ` const page = await import(${JSON.stringify(createPageComponentImport(page.path))})`,\n ' return [page, context, params]',\n ' }',\n `}, ${JSON.stringify(page.config)})`\n ].join('\\n')\n )\n return `[\\n${webRoutes.join(',\\n')}\\n]`\n}\n","import path from 'node:path'\nimport { recursiveMerge } from '@tarojs/helper'\nimport { Weapp as WechatPlatform } from '@tarojs/plugin-platform-weapp'\nimport type { UserConfig } from 'vite'\nimport { isProd, nodeRequire } from '../constants.ts'\nimport type { JsonObject, TaroBuildContext, TaroPageOption } from '../types.ts'\nimport { createPageComponentImport, normalizeModuleId } from '../utils.ts'\n\nconst virtualWxAppId = 'virtual:vite-plugin-taro/wx/app'\nconst virtualWxCompId = 'virtual:vite-plugin-taro/wx/comp'\nconst virtualWxPagePrefix = 'virtual:vite-plugin-taro/wx/page/'\n\n/**\n * Checks whether an id belongs to a wx virtual module.\n */\nexport function isWxVirtualModuleId(id: string): boolean {\n return id === virtualWxAppId || id === virtualWxCompId || id.startsWith(virtualWxPagePrefix)\n}\n\nexport function loadWxVirtualModule(cleanId: string, context: TaroBuildContext): string | undefined {\n if (cleanId === virtualWxAppId) {\n return createWxAppEntry(context)\n }\n\n if (cleanId === virtualWxCompId) {\n return createWxCompEntry()\n }\n\n if (!cleanId.startsWith(virtualWxPagePrefix)) {\n return\n }\n\n const pagePath = cleanId.slice(virtualWxPagePrefix.length)\n const page = context.pages.find((candidate) => candidate.path === pagePath)\n if (page) {\n return createWxPageEntry(page)\n }\n}\n\nconst taroWechatComponentsReactPath = nodeRequire.resolve('@tarojs/plugin-platform-weapp/dist/components-react')\nconst pluginSourcePath = normalizeModuleId(path.dirname(nodeRequire.resolve('vite-plugin-taro/vite')))\nconst taroVersion = String(nodeRequire('@tarojs/runtime/package.json').version)\n\n/**\n * Configures wx target entry, output, and chunk layout.\n */\nexport function createWxViteConfig(context: TaroBuildContext): UserConfig {\n return {\n define: createWechatTaroDefines(),\n // https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniCombination.ts#L22-L84\n resolve: {\n // https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniBaseConfig.ts#L44-L73\n alias: [{ find: /^@tarojs\\/components$/, replacement: taroWechatComponentsReactPath }]\n },\n build: {\n target: 'es2018',\n assetsInlineLimit: 1024,\n cssCodeSplit: false,\n minify: isProd,\n rolldownOptions: {\n // Start from app; page/component chunks below mirror Taro Webpack's generated entries.\n input: { app: virtualWxAppId },\n experimental: {\n // Rolldown's dev debug comments include virtual IDs like \"\\0virtual:...\".\n // WeChat DevTools can blank-screen on those NUL markers, so disable them at the source.\n attachDebugInfo: 'none'\n },\n output: {\n format: 'cjs',\n entryFileNames: '[name].js',\n assetFileNames: 'assets/[name][extname]',\n chunkFileNames: createWechatChunkFileName,\n strictExecutionOrder: true,\n codeSplitting: {\n includeDependenciesRecursively: false,\n minSize: 0,\n // https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniCombination.ts#L96-L144\n groups: [\n { name: 'taro', test: isWxTaroChunkModule, priority: 100 },\n { name: 'vendors', test: isNodeModule, priority: 10 },\n { name: 'common', minShareCount: 2, minModuleSize: 1, priority: 1 }\n ]\n }\n }\n }\n }\n }\n}\n\n/**\n * Creates compile-time constants expected by Taro's WeChat runtime packages.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniWebpackPlugin.ts#L67-L94\n */\nfunction createWechatTaroDefines(): Record<string, string> {\n return {\n 'process.env.FRAMEWORK': JSON.stringify('react'),\n 'process.env.SUPPORT_TARO_POLYFILL': JSON.stringify('disabled'),\n 'process.env.TARO_ENV': JSON.stringify('weapp'),\n 'process.env.TARO_PLATFORM': JSON.stringify('mini'),\n 'process.env.TARO_VERSION': JSON.stringify(taroVersion),\n IS_H5: 'false',\n IS_WEAPP: 'true',\n ENABLE_ADJACENT_HTML: 'false',\n ENABLE_CLONE_NODE: 'false',\n ENABLE_CONTAINS: 'false',\n ENABLE_INNER_HTML: 'false',\n ENABLE_MUTATION_OBSERVER: 'false',\n ENABLE_SIZE_APIS: 'false',\n ENABLE_TEMPLATE_CONTENT: 'false'\n }\n}\n\n/**\n * Checks whether a module should live in the Taro/framework base chunk.\n * vite-plugin-taro support modules are kept with Taro so pages do not duplicate runtime facades.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniCombination.ts#L141-L144\n */\nfunction isWxTaroChunkModule(id: string): boolean {\n const normalizedId = normalizeModuleId(id)\n return normalizedId.includes('/node_modules/@tarojs/') || normalizedId.startsWith(`${pluginSourcePath}/`)\n}\n\n/**\n * Names Rolldown's helper chunk like Taro webpack's runtime chunk.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniCombination.ts#L96-L103\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniCombination.ts#L115-L117\n */\nfunction createWechatChunkFileName(chunkInfo: { name: string }): string {\n return `${chunkInfo.name === 'rolldown-runtime' ? 'runtime' : chunkInfo.name}.js`\n}\n\n/**\n * Checks whether a module is a third-party dependency chunk candidate.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/webpack/MiniCombination.ts#L132-L139\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-helper/src/utils.ts#L32-L36\n */\nfunction isNodeModule(id: string): boolean {\n return normalizeModuleId(id).includes('/node_modules/')\n}\n\ntype WechatAssetSource = string | Uint8Array\n\ntype WechatBundleModule = {\n renderedExports?: string[]\n}\n\ntype WechatBundleItem = {\n type: 'asset' | 'chunk'\n source?: WechatAssetSource\n modules?: Record<string, WechatBundleModule>\n}\n\ntype WechatBundle = Record<string, WechatBundleItem>\n\ntype WechatTemplateComponentConfig = {\n includes: Set<string>\n exclude: Set<string>\n thirdPartyComponents: Map<string, Set<string>>\n includeAll: boolean\n}\n\ntype WechatChunkEmitter = {\n emitFile(chunk: { type: 'chunk'; id: string; fileName: string; implicitlyLoadedAfterOneOf: string[] }): string\n}\n\ntype WechatAssetEmitter = {\n emitFile(asset: { type: 'asset'; fileName: string; source: WechatAssetSource }): string\n}\n\n/**\n * Emits page and component chunks like Taro Webpack's MiniPlugin generated entries.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L228-L243\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L743-L777\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/TaroSingleEntryPlugin.ts#L18-L38\n */\nexport function emitWechatImplicitChunksForVirtualApp(\n emitter: WechatChunkEmitter,\n context: TaroBuildContext,\n cleanId: string\n): void {\n if (context.target !== 'wx' || cleanId !== virtualWxAppId) return\n\n for (const page of context.pages) {\n emitter.emitFile({\n type: 'chunk',\n id: `${virtualWxPagePrefix}${page.path}`,\n fileName: `${page.path}.js`,\n implicitlyLoadedAfterOneOf: [cleanId]\n })\n }\n emitter.emitFile({\n type: 'chunk',\n id: virtualWxCompId,\n fileName: 'comp.js',\n implicitlyLoadedAfterOneOf: [cleanId]\n })\n}\n\n/**\n * Builds the generated WeChat app entry that registers Taro's React App config.\n * vite-plugin-taro omits Taro's generated pxTransform initialization because styles are handled by Tailwind.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-loader/src/app.ts#L54-L63\n */\nexport function createWxAppEntry(context: TaroBuildContext): string {\n const wechatAppConfigCode = JSON.stringify(context.appConfig)\n\n return `import { createReactApp, ReactDOM } from 'vite-plugin-taro/shim/wx'\nimport React from 'react'\nimport AppComponent from '${context.appComponentImport}'\n\nconst appConfig = ${wechatAppConfigCode}\nApp(createReactApp(AppComponent, React, ReactDOM, appConfig))\n`\n}\n\n/**\n * Builds a generated WeChat page entry that registers Taro's Page config.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-loader/src/page.ts#L52-L78\n */\nexport function createWxPageEntry(pageOption: TaroPageOption): string {\n const wechatPageConfigCode = JSON.stringify(pageOption.config)\n const pageComponentImport = createPageComponentImport(pageOption.path)\n return `import { createPageConfig } from 'vite-plugin-taro/shim/wx'\nimport PageComponent from '${pageComponentImport}'\n\nconst pageConfig = ${wechatPageConfigCode}\nconst taroPageConfig = createPageConfig(PageComponent, '${pageOption.path}', { root: { cn: [] } }, pageConfig)\nif (PageComponent && PageComponent.behaviors) {\n taroPageConfig.behaviors = (taroPageConfig.behaviors || []).concat(PageComponent.behaviors)\n}\nPage(taroPageConfig)\n`\n}\n\n/**\n * Builds the generated JS companion for comp.wxml/comp.json. Without it WeChat\n * can load recursive markup, but it will not have Taro's properties or `eh` event\n * dispatch method.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/template/comp.ts#L1-L4\n */\nexport function createWxCompEntry(): string {\n return `import { createRecursiveComponentConfig } from 'vite-plugin-taro/shim/wx'\n\nComponent(createRecursiveComponentConfig())\n`\n}\n\n/**\n * Creates Taro-style Mini Program template/config/style companion files.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-platform-weapp/src/program.ts#L33-L55\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L1198-L1311\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L1346-L1390\n */\nexport function emitWechatAssets(emitter: WechatAssetEmitter, bundle: WechatBundle, context: TaroBuildContext): void {\n if (context.target !== 'wx') return\n for (const asset of createWechatAssets(bundle, context)) {\n emitter.emitFile({ type: 'asset', fileName: asset.fileName, source: asset.source })\n }\n}\n\nfunction createWechatAssets(\n bundle: WechatBundle,\n context: TaroBuildContext\n): { fileName: string; source: WechatAssetSource }[] {\n const builder = createWechatTemplateBuilder()\n\n return [\n { fileName: 'app.json', source: stringifyJsonAsset(context.appConfig) },\n { fileName: 'app.wxss', source: collectWechatBundleWxss(bundle) },\n { fileName: 'base.wxml', source: builder.buildTemplate(collectWechatTemplateComponentConfig(bundle)) },\n { fileName: 'utils.wxs', source: builder.buildXScript() },\n { fileName: 'comp.wxml', source: builder.buildBaseComponentTemplate('.wxml') },\n { fileName: 'comp.json', source: stringifyJsonAsset(createWechatCompJson()) },\n { fileName: 'project.config.json', source: stringifyJsonAsset(context.projectConfigJson) },\n { fileName: 'sitemap.json', source: stringifyJsonAsset(context.sitemapJson) },\n ...context.pages.flatMap((page) => [\n {\n fileName: `${page.path}.wxml`,\n source: builder.buildPageTemplate(relativeWechatRootAssetFromPage(page.path, 'base.wxml'), {\n content: page.config,\n path: page.path\n })\n },\n {\n fileName: `${page.path}.json`,\n source: stringifyJsonAsset({\n ...page.config,\n usingComponents: {\n comp: relativeWechatRootAssetFromPage(page.path, 'comp')\n }\n })\n },\n { fileName: `${page.path}.wxss`, source: '' }\n ])\n ]\n}\n\nfunction createWechatTemplateBuilder() {\n const wechatPlatform = new WechatPlatform(\n { helper: { recursiveMerge }, modifyWebpackChain() {}, registerPlatform() {} },\n {},\n {}\n )\n wechatPlatform.modifyTemplate({})\n return wechatPlatform.template\n}\n\n/**\n * Computes a WeChat import path from a page file to a generated root asset.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L1270-L1298\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-helper/src/utils.ts#L74-L88\n */\nfunction relativeWechatRootAssetFromPage(wechatPagePath: string, wechatRootAsset: string): string {\n const wechatPageDir = path.posix.dirname(wechatPagePath)\n const relativePath = path.posix.relative(wechatPageDir, wechatRootAsset)\n return relativePath.startsWith('.') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Builds Taro's template component include config from official defaults plus\n * the component exports that Rolldown kept in the @tarojs/components bundle.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/utils/component.ts#L3-L8\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/TaroComponentsExportsPlugin.ts#L83-L124\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/TaroLoadChunksPlugin.ts#L165-L180\n */\nfunction collectWechatTemplateComponentConfig(bundle: WechatBundle): WechatTemplateComponentConfig {\n const wechatComponentConfig: WechatTemplateComponentConfig = {\n includes: new Set([\n 'view',\n 'catch-view',\n 'static-view',\n 'pure-view',\n 'click-view',\n 'scroll-view',\n 'image',\n 'static-image',\n 'text',\n 'static-text'\n ]),\n exclude: new Set(),\n thirdPartyComponents: new Map(),\n includeAll: false\n }\n\n const wechatComponentsModule = findBundleModule(bundle, taroWechatComponentsReactPath)\n for (const item of wechatComponentsModule?.renderedExports ?? []) {\n wechatComponentConfig.includes.add(toDashed(item))\n }\n\n return wechatComponentConfig\n}\n\nfunction toDashed(s: string) {\n return s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()\n}\n\n/**\n * Finds a module record inside the generated bundle by normalized module ID.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/TaroComponentsExportsPlugin.ts#L83-L124\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/TaroLoadChunksPlugin.ts#L165-L180\n */\nfunction findBundleModule(bundle: WechatBundle, resolvedId: string): WechatBundleModule | undefined {\n const normalizedResolvedId = normalizeModuleId(resolvedId)\n for (const item of Object.values(bundle)) {\n if (item.type !== 'chunk') {\n continue\n }\n\n const found = Object.entries(item.modules ?? {}).find(([id]) => normalizeModuleId(id) === normalizedResolvedId)\n if (found) {\n return found[1]\n }\n }\n}\n\n/**\n * Creates the JSON config for Taro's shared recursive component.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L1228-L1252\n */\nfunction createWechatCompJson(): JsonObject {\n return {\n component: true,\n styleIsolation: 'apply-shared',\n // Taro's recursive template can nest <comp />, so the component references\n // itself just like the official runner output.\n usingComponents: { comp: './comp' }\n }\n}\n\n/**\n * Converts a WeChat-emitted asset's source into text.\n */\nfunction getWechatAssetSource(item: WechatBundleItem): string {\n if (typeof item.source === 'string') return item.source\n return item.source ? new TextDecoder().decode(item.source) : ''\n}\n\n/**\n * Flattens Vite-emitted CSS into app.wxss and removes the intermediate CSS asset.\n * This is vite-plugin-taro's Vite equivalent of Taro Webpack's app/common style consolidation.\n *\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L1310-L1311\n * https://github.com/NervJS/taro/blob/f0e5c39d5f04290db975670411e23c3a396e15f8/packages/taro-webpack5-runner/src/plugins/MiniPlugin.ts#L1471-L1528\n */\nfunction collectWechatBundleWxss(bundle: WechatBundle): string {\n const wechatWxssChunks: string[] = []\n for (const [fileName, item] of Object.entries(bundle)) {\n if (item.type !== 'asset' || !fileName.endsWith('.css')) continue\n const source = getWechatAssetSource(item)\n if (source) wechatWxssChunks.push(source)\n delete bundle[fileName]\n }\n return wechatWxssChunks.join('\\n')\n}\n\n/**\n * Serializes generated Mini Program JSON assets; vite-plugin-taro pretty-prints non-prod output.\n */\nfunction stringifyJsonAsset(value: JsonObject): string {\n return isProd ? JSON.stringify(value) : JSON.stringify(value, null, 2)\n}\n","import type { Plugin, PluginOption, UserConfig } from 'vite'\nimport { createTaroConditionalDirectivePlugin } from './plugins.ts'\nimport { createTailwindcssPlugins } from './tailwindcss.ts'\nimport {\n createH5SupportPlugins,\n createH5ViteConfig,\n createWebIndexHtmlTags,\n isH5VirtualModuleId,\n loadH5VirtualModule\n} from './targets/h5.ts'\nimport {\n createWxViteConfig,\n emitWechatAssets,\n emitWechatImplicitChunksForVirtualApp,\n isWxVirtualModuleId,\n loadWxVirtualModule\n} from './targets/wx.ts'\nimport type { TaroBuildContext, TaroPluginOptions } from './types.ts'\nimport { stripVirtualPrefix, toImportPath } from './utils.ts'\n\n/**\n * Creates the Vite/Rolldown plugin that emits either WeChat Mini Program files\n * or a Taro Web app using the official Taro runtime packages.\n */\nexport default function taro(options: TaroPluginOptions): PluginOption[] {\n const context = createTaroBuildContext(options)\n\n return [\n createTaroConditionalDirectivePlugin(context),\n ...createTargetSupportPlugins(context),\n ...createTailwindcssPlugins(context),\n createTaroPlugin(context)\n ]\n}\n\nfunction createTargetSupportPlugins(context: TaroBuildContext): PluginOption[] {\n switch (context.target) {\n case 'h5':\n return createH5SupportPlugins()\n default:\n return []\n }\n}\n\n/**\n * Creates the vite-plugin-taro plugin that emits H5 or Wx outputs.\n */\nfunction createTaroPlugin(context: TaroBuildContext): Plugin {\n return {\n name: 'vite-plugin-taro',\n enforce: 'post',\n\n /** Configures Vite/Rolldown for the active target. */\n config: {\n order: 'pre',\n handler: (): UserConfig => {\n return context.target === 'wx' ? createWxViteConfig(context) : createH5ViteConfig()\n }\n },\n\n /** Marks generated app/page/component entries as virtual modules. */\n resolveId(id) {\n if (isWxVirtualModuleId(id) || isH5VirtualModuleId(id)) return `\\0${id}`\n },\n\n /** Supplies source code for each virtual entry module. */\n load(id) {\n const cleanId = stripVirtualPrefix(id)\n\n emitWechatImplicitChunksForVirtualApp(this, context, cleanId)\n\n return loadWxVirtualModule(cleanId, context) ?? loadH5VirtualModule(cleanId, context)\n },\n\n /** Injects the generated Web entry into the app shell before Vite scans HTML imports. */\n transformIndexHtml: {\n order: 'pre',\n handler() {\n return createWebIndexHtmlTags(context)\n }\n },\n\n /** Emits the WeChat JSON/WXML/WXS/WXSS files that are not JS bundle chunks. */\n generateBundle(_, bundle) {\n emitWechatAssets(this, bundle, context)\n }\n }\n}\n\n/**\n * Normalizes user options into the shared data used by both target builders.\n */\nfunction createTaroBuildContext(options: TaroPluginOptions): TaroBuildContext {\n return {\n target: options.target,\n appComponentImport: toImportPath(options.app),\n pages: options.pages,\n appConfig: {\n ...options.appJson,\n pages: options.pages.map((page) => page.path)\n },\n projectConfigJson: options.projectConfigJson,\n sitemapJson: options.sitemapJson\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AASA,SAAgB,0BAA0B,UAA0B;CAChE,OAAO,aAAa,OAAO,SAAS,KAAK;AAC7C;;;;AAKA,SAAgB,aAAa,UAA0B;CACnD,OAAO,KAAK,QAAQ,QAAQ;AAChC;;;;AAKA,SAAgB,mBAAmB,IAAoB;CACnD,OAAO,GAAG,WAAW,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI;AAC/C;;;;;;AAOA,SAAgB,kBAAkB,IAAoB;CAClD,OAAO,GAAG,QAAQ,OAAO,GAAG,EAAE,QAAQ,SAAS,EAAE;AACrD;;;;;;;;ACzBA,SAAgB,qCAAqC,SAAmC;CACpF,MAAM,SAAS,QAAQ;CACvB,OAAO;EACH,MAAM;EACN,SAAS;EACT,UAAU,MAAM,IAAI;GAChB,IAAI,CAAC,6BAA6B,EAAE,KAAK,CAAC,KAAK,SAAS,KAAK,GAAG;GAChE,OAAO;IAAE,MAAM,+BAA+B,MAAM,MAAM;IAAG,KAAK;GAAK;EAC3E;CACJ;AACJ;;;;;;AAOA,SAAS,6BAA6B,IAAqB;CACvD,MAAM,eAAe,kBAAkB,EAAE;CACzC,IAAI,aAAa,SAAS,gBAAgB,GAAG,OAAO;CACpD,OAAO,mDAAmD,KAAK,YAAY;AAC/E;;;;;;AAoBA,SAAS,+BAA+B,MAAc,Q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AmC;CACzD,OAAO;EACH,MAAM;EACN,SAAS;;EAGT,QAAQ;GACJ,OAAO;GACP,eAA2B;IACvB,OAAO,QAAQ,WAAW,OAAO,mBAAmB,OAAO,IAAI,mBAAmB;GACtF;EACJ;;EAGA,UAAU,IAAI;GACV,IAAI,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,GAAG,OAAO,KAAK;EACxE;;EAGA,KAAK,IAAI;GACL,MAAM,UAAU,mBAAmB,EAAE;GAErC,sCAAsC,MAAM,SAAS,OAAO;GAE5D,OAAO,oBAAoB,SAAS,OAAO,KAAK,oBAAoB,SAAS,OAAO;EACxF;;EAGA,oBAAoB;GAChB,OAAO;GACP,UAAU;IACN,OAAO,uBAAuB,OAAO;GACzC;EACJ;;EAGA,eAAe,GAAG,QAAQ;GACtB,iBAAiB,MAAM,QAAQ,OAAO;EAC1C;CACJ;AACJ;;;;AAKA,SAAS,uBAAuB,SAA8C;CAC1E,OAAO;EACH,QAAQ,QAAQ;EAChB,oBAAoB,aAAa,QAAQ,GAAG;EAC5C,OAAO,QAAQ;EACf,WAAW;GACP,GAAG,QAAQ;GACX,OAAO,QAAQ,MAAM,KAAK,SAAS,KAAK,IAAI;EAChD;EACA,mBAAmB,QAAQ;EAC3B,aAAa,QAAQ;CACzB;AACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vite-plugin-taro",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Vite 8 plugin for building one React/Taro codebase for WeChat Mini Program and H5 targets.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/vite.js",
|
|
7
|
+
"module": "./dist/vite.js",
|
|
8
|
+
"types": "./dist/vite.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/vite.d.ts",
|
|
12
|
+
"import": "./dist/vite.js",
|
|
13
|
+
"default": "./dist/vite.js"
|
|
14
|
+
},
|
|
15
|
+
"./vite": {
|
|
16
|
+
"types": "./dist/vite.d.ts",
|
|
17
|
+
"import": "./dist/vite.js",
|
|
18
|
+
"default": "./dist/vite.js"
|
|
19
|
+
},
|
|
20
|
+
"./components": {
|
|
21
|
+
"types": "./dist/public/components.d.ts",
|
|
22
|
+
"import": "./dist/public/components.js",
|
|
23
|
+
"default": "./dist/public/components.js"
|
|
24
|
+
},
|
|
25
|
+
"./taro": {
|
|
26
|
+
"types": "./dist/public/taro.d.ts",
|
|
27
|
+
"import": "./dist/public/taro.js",
|
|
28
|
+
"default": "./dist/public/taro.js"
|
|
29
|
+
},
|
|
30
|
+
"./shim/h5": {
|
|
31
|
+
"types": "./dist/shim/h5.d.ts",
|
|
32
|
+
"import": "./dist/shim/h5.js",
|
|
33
|
+
"default": "./dist/shim/h5.js"
|
|
34
|
+
},
|
|
35
|
+
"./shim/wx": {
|
|
36
|
+
"types": "./dist/shim/wx.d.ts",
|
|
37
|
+
"import": "./dist/shim/wx.js",
|
|
38
|
+
"default": "./dist/shim/wx.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"LICENSE",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"keywords": [
|
|
48
|
+
"vite",
|
|
49
|
+
"vite-plugin",
|
|
50
|
+
"taro",
|
|
51
|
+
"wechat",
|
|
52
|
+
"mini-program",
|
|
53
|
+
"react"
|
|
54
|
+
],
|
|
55
|
+
"author": "felix",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@rolldown/plugin-babel": "^0.2.3",
|
|
65
|
+
"@tarojs/components": "^4.2.0",
|
|
66
|
+
"@tarojs/helper": "^4.2.0",
|
|
67
|
+
"@tarojs/plugin-platform-h5": "^4.2.0",
|
|
68
|
+
"@tarojs/plugin-platform-weapp": "^4.2.0",
|
|
69
|
+
"@tarojs/router": "^4.2.0",
|
|
70
|
+
"@tarojs/runtime": "^4.2.0",
|
|
71
|
+
"@tarojs/taro": "^4.2.0",
|
|
72
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
73
|
+
"babel-plugin-transform-taroapi": "^4.2.0",
|
|
74
|
+
"tailwindcss": "^4.3.0",
|
|
75
|
+
"weapp-tailwindcss": "^5.0.5",
|
|
76
|
+
"@tarojs/plugin-framework-react": "npm:vite-plugin-taro-plugin-framework-react@4.2.0-react19.0",
|
|
77
|
+
"@tarojs/react": "npm:vite-plugin-taro-react@4.2.0-react19.0"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"react": "^19.0.0",
|
|
81
|
+
"react-dom": "^19.0.0",
|
|
82
|
+
"vite": "^8.0.0"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@types/node": "^24.10.1",
|
|
86
|
+
"@typescript/native-preview": "latest",
|
|
87
|
+
"typescript": "^5.9.3",
|
|
88
|
+
"vite": "^8.0.16",
|
|
89
|
+
"vite-plugin-dts": "^5.0.2"
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"clean": "rm -rf dist",
|
|
93
|
+
"build": "pnpm -w prepare:taro && pnpm clean && vite build",
|
|
94
|
+
"typecheck": "pnpm -w prepare:taro && tsgo --project tsconfig.json",
|
|
95
|
+
"pack:dry": "pnpm pack --dry-run"
|
|
96
|
+
}
|
|
97
|
+
}
|