vite-plugin-taro 0.5.6 → 0.5.7
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/dist/node/plugins/wx/dev/plugins.d.ts +22 -0
- package/dist/node/plugins/wx/dev/plugins.js +158 -0
- package/dist/node/plugins/wx/dev/react-refresh.d.ts +1 -2
- package/dist/node/plugins/wx/dev/react-refresh.js +12 -14
- package/dist/node/plugins/wx/dev/wx-dev-options.js +2 -1
- package/dist/node/plugins/wx/module.d.ts +2 -0
- package/dist/node/plugins/wx/module.js +2 -0
- package/dist/node/plugins/wx/plugins.js +1 -1
- package/dist/runtime/wx/capsule/page.js +1 -71
- package/dist/runtime/wx/dev/dev-runtime.js +161 -84
- package/package.json +3 -3
- package/src/node/plugins/wx/dev/plugins.ts +170 -0
- package/src/node/plugins/wx/dev/react-refresh.ts +12 -15
- package/src/node/plugins/wx/dev/wx-dev-options.ts +2 -1
- package/src/node/plugins/wx/module.ts +3 -0
- package/src/node/plugins/wx/plugins.ts +1 -1
- package/src/runtime/wx/capsule/page.ts +1 -93
- package/src/runtime/wx/dev/dev-runtime.ts +233 -89
- package/src/runtime/wx/wechat.d.ts +3 -6
- package/dist/node/plugins/wx/dev/plugin.d.ts +0 -7
- package/dist/node/plugins/wx/dev/plugin.js +0 -73
- package/src/node/plugins/wx/dev/plugin.ts +0 -82
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { PluginOption } from 'vite'
|
|
2
|
-
import { transformWithOxc } from 'vite'
|
|
3
|
-
import type { VitePluginTaroOptions } from '../../../../options.ts'
|
|
4
|
-
import { esTarget } from '../../../utils/constant.ts'
|
|
5
|
-
import { rolldownRuntimeId } from '../module.ts'
|
|
6
|
-
import { memoize } from '../../../utils/memoize.ts'
|
|
7
|
-
import { createWxDevHost, type WxDevHost } from './dev-host.ts'
|
|
8
|
-
import { createWxReactRefreshTransforms } from './react-refresh.ts'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Adds the serve-only bundled-development plugin set for the wx target: the dev adapter
|
|
12
|
-
* (config, runtime lowering, dev host) plus the React Refresh adaptation transforms.
|
|
13
|
-
*/
|
|
14
|
-
export function createWxDevelopmentPlugin(options: VitePluginTaroOptions): PluginOption[] {
|
|
15
|
-
let host: WxDevHost | null = null
|
|
16
|
-
|
|
17
|
-
return [
|
|
18
|
-
{
|
|
19
|
-
name: 'vpt:wx-dev',
|
|
20
|
-
apply: 'serve',
|
|
21
|
-
|
|
22
|
-
config() {
|
|
23
|
-
return {
|
|
24
|
-
build: {
|
|
25
|
-
// Disable maps in resolved environment config as well as final output so Oxc and Babel skip producing
|
|
26
|
-
// intermediate maps that Rolldown would discard.
|
|
27
|
-
sourcemap: false
|
|
28
|
-
},
|
|
29
|
-
experimental: {
|
|
30
|
-
// Ask Vite to resolve its bundled-development graph and expose the private adapter instance. The wx
|
|
31
|
-
// configureServer hook replaces only its startup method with the directly writing DevEngine.
|
|
32
|
-
bundledDev: true
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
transform: {
|
|
38
|
-
order: 'post',
|
|
39
|
-
// The dev-mode transform assembles the runtime chunk (Rolldown's base runtime
|
|
40
|
-
// plus our injected implement) as this module's transform output, which
|
|
41
|
-
// bypasses the build's es2018 lowering. Real-device engines and WeChat's
|
|
42
|
-
// upload parser predate class fields and nullish operators, so the assembled
|
|
43
|
-
// runtime is lowered here — the only module that needs it. The exact id
|
|
44
|
-
// filter needs no code scan; the id must stay in sync with rolldownRuntimeId
|
|
45
|
-
// in module.ts (kept as a regex for the Rolldown-side filter).
|
|
46
|
-
filter: { id: /^\0rolldown\/runtime\.js(?:\?|$)/ },
|
|
47
|
-
handler(code, id) {
|
|
48
|
-
// The `setPublicClassFields` assumption emits plain `this.x = ...`
|
|
49
|
-
// assignments instead of external helpers, whose references the later
|
|
50
|
-
// minifier would mangle.
|
|
51
|
-
return fixRolldownRuntime(code)
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
configureServer: {
|
|
56
|
-
// Install after Vite and user plugins have finished configuring the environment, but before server.listen()
|
|
57
|
-
// asks bundledDev to create its hard-coded skip-write DevEngine.
|
|
58
|
-
order: 'post',
|
|
59
|
-
async handler(server) {
|
|
60
|
-
host = await createWxDevHost({ server, options })
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
closeBundle() {
|
|
65
|
-
return host?.close()
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
...createWxReactRefreshTransforms()
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// The assembled runtime chunk is byte-identical on every build (the base runtime and the
|
|
73
|
-
// bundled implement are immutable for the server's lifetime), so the lowering runs once
|
|
74
|
-
// and every build reuses it.
|
|
75
|
-
const fixRolldownRuntime = memoize((code: string) => {
|
|
76
|
-
return transformWithOxc(code, rolldownRuntimeId, {
|
|
77
|
-
lang: 'js',
|
|
78
|
-
target: esTarget,
|
|
79
|
-
sourcemap: false,
|
|
80
|
-
assumptions: { setPublicClassFields: true }
|
|
81
|
-
})
|
|
82
|
-
})
|