with-zephyr 0.1.0-next.1 → 0.1.1-next.2
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 +3 -1
- package/dist/index.js +486 -430
- package/dist/zephyr-manifest.json +6 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -34,13 +34,14 @@ bunx with-zephyr
|
|
|
34
34
|
|
|
35
35
|
## Supported Bundlers
|
|
36
36
|
|
|
37
|
-
This codemod supports **
|
|
37
|
+
This codemod supports **12+ bundlers** with their respective Zephyr plugins:
|
|
38
38
|
|
|
39
39
|
- **Webpack** ([`zephyr-webpack-plugin`](https://www.npmjs.com/package/zephyr-webpack-plugin))
|
|
40
40
|
- **Rspack** ([`zephyr-rspack-plugin`](https://www.npmjs.com/package/zephyr-rspack-plugin))
|
|
41
41
|
- **Vite** ([`vite-plugin-zephyr`](https://www.npmjs.com/package/vite-plugin-zephyr))
|
|
42
42
|
- **Rollup** ([`rollup-plugin-zephyr`](https://www.npmjs.com/package/rollup-plugin-zephyr))
|
|
43
43
|
- **Rolldown** ([`zephyr-rolldown-plugin`](https://www.npmjs.com/package/zephyr-rolldown-plugin))
|
|
44
|
+
- **Astro** ([`zephyr-astro-integration`](https://www.npmjs.com/package/zephyr-astro-integration))
|
|
44
45
|
- **Modern.js** ([`zephyr-modernjs-plugin`](https://www.npmjs.com/package/zephyr-modernjs-plugin))
|
|
45
46
|
- **RSPress** ([`zephyr-rspress-plugin`](https://www.npmjs.com/package/zephyr-rspress-plugin))
|
|
46
47
|
- **Parcel** ([`parcel-reporter-zephyr`](https://www.npmjs.com/package/parcel-reporter-zephyr))
|
|
@@ -241,6 +242,7 @@ The codemod automatically detects and processes these configuration files:
|
|
|
241
242
|
- `vite.config.js/ts/mjs`
|
|
242
243
|
- `rollup.config.js/ts/mjs`
|
|
243
244
|
- `rolldown.config.js/ts/mjs`
|
|
245
|
+
- `astro.config.js/ts/mjs/mts`
|
|
244
246
|
- `modern.config.js/ts/mjs`
|
|
245
247
|
- `rspress.config.js/ts/mjs`
|
|
246
248
|
- `rsbuild.config.js/ts/mjs`
|
package/dist/index.js
CHANGED
|
@@ -47910,280 +47910,302 @@ const esm_glob = Object.assign(glob_, {
|
|
|
47910
47910
|
unescape: unescape_unescape
|
|
47911
47911
|
});
|
|
47912
47912
|
esm_glob.glob = esm_glob;
|
|
47913
|
-
const
|
|
47914
|
-
|
|
47915
|
-
|
|
47916
|
-
|
|
47917
|
-
|
|
47918
|
-
|
|
47919
|
-
|
|
47920
|
-
|
|
47921
|
-
|
|
47922
|
-
|
|
47923
|
-
|
|
47924
|
-
|
|
47925
|
-
|
|
47926
|
-
|
|
47927
|
-
|
|
47928
|
-
|
|
47929
|
-
|
|
47930
|
-
|
|
47931
|
-
|
|
47932
|
-
|
|
47933
|
-
|
|
47934
|
-
|
|
47935
|
-
|
|
47936
|
-
|
|
47937
|
-
|
|
47938
|
-
|
|
47939
|
-
|
|
47940
|
-
|
|
47941
|
-
|
|
47942
|
-
|
|
47943
|
-
|
|
47944
|
-
|
|
47945
|
-
|
|
47946
|
-
|
|
47947
|
-
|
|
47948
|
-
|
|
47949
|
-
|
|
47950
|
-
|
|
47951
|
-
|
|
47952
|
-
|
|
47953
|
-
|
|
47954
|
-
|
|
47955
|
-
|
|
47956
|
-
|
|
47957
|
-
|
|
47958
|
-
|
|
47959
|
-
|
|
47960
|
-
|
|
47961
|
-
|
|
47962
|
-
|
|
47963
|
-
|
|
47964
|
-
|
|
47965
|
-
|
|
47966
|
-
|
|
47967
|
-
|
|
47968
|
-
|
|
47969
|
-
|
|
47970
|
-
|
|
47971
|
-
|
|
47972
|
-
|
|
47973
|
-
|
|
47974
|
-
|
|
47975
|
-
|
|
47976
|
-
|
|
47977
|
-
|
|
47978
|
-
|
|
47979
|
-
|
|
47980
|
-
|
|
47981
|
-
|
|
47982
|
-
|
|
47983
|
-
|
|
47984
|
-
|
|
47985
|
-
|
|
47986
|
-
|
|
47987
|
-
|
|
47988
|
-
|
|
47989
|
-
|
|
47990
|
-
|
|
47991
|
-
|
|
47992
|
-
|
|
47993
|
-
|
|
47994
|
-
|
|
47995
|
-
|
|
47996
|
-
|
|
47997
|
-
|
|
47998
|
-
|
|
47999
|
-
|
|
48000
|
-
|
|
48001
|
-
|
|
48002
|
-
|
|
48003
|
-
|
|
48004
|
-
|
|
48005
|
-
|
|
48006
|
-
|
|
48007
|
-
|
|
48008
|
-
|
|
48009
|
-
|
|
48010
|
-
|
|
48011
|
-
|
|
48012
|
-
|
|
48013
|
-
|
|
48014
|
-
|
|
48015
|
-
|
|
48016
|
-
|
|
48017
|
-
|
|
48018
|
-
|
|
48019
|
-
|
|
48020
|
-
|
|
48021
|
-
|
|
48022
|
-
|
|
48023
|
-
|
|
48024
|
-
|
|
48025
|
-
|
|
48026
|
-
|
|
48027
|
-
|
|
48028
|
-
|
|
48029
|
-
|
|
48030
|
-
|
|
48031
|
-
|
|
48032
|
-
|
|
48033
|
-
'
|
|
48034
|
-
|
|
48035
|
-
|
|
48036
|
-
|
|
48037
|
-
|
|
48038
|
-
|
|
48039
|
-
|
|
48040
|
-
|
|
48041
|
-
|
|
48042
|
-
|
|
48043
|
-
|
|
48044
|
-
|
|
48045
|
-
|
|
48046
|
-
|
|
48047
|
-
|
|
48048
|
-
|
|
48049
|
-
|
|
48050
|
-
|
|
48051
|
-
|
|
48052
|
-
|
|
48053
|
-
|
|
48054
|
-
|
|
48055
|
-
|
|
48056
|
-
|
|
48057
|
-
|
|
48058
|
-
|
|
48059
|
-
|
|
48060
|
-
|
|
48061
|
-
|
|
48062
|
-
|
|
48063
|
-
|
|
48064
|
-
|
|
48065
|
-
|
|
48066
|
-
|
|
48067
|
-
|
|
48068
|
-
|
|
48069
|
-
|
|
48070
|
-
|
|
48071
|
-
|
|
48072
|
-
|
|
48073
|
-
|
|
48074
|
-
|
|
48075
|
-
|
|
48076
|
-
|
|
48077
|
-
|
|
48078
|
-
|
|
48079
|
-
|
|
48080
|
-
|
|
48081
|
-
|
|
48082
|
-
|
|
48083
|
-
|
|
48084
|
-
|
|
48085
|
-
|
|
48086
|
-
|
|
48087
|
-
|
|
48088
|
-
|
|
48089
|
-
|
|
48090
|
-
|
|
48091
|
-
|
|
48092
|
-
|
|
48093
|
-
|
|
48094
|
-
|
|
48095
|
-
|
|
48096
|
-
|
|
48097
|
-
|
|
48098
|
-
|
|
48099
|
-
|
|
48100
|
-
|
|
48101
|
-
|
|
48102
|
-
|
|
48103
|
-
|
|
48104
|
-
|
|
48105
|
-
|
|
48106
|
-
|
|
48107
|
-
|
|
48108
|
-
|
|
48109
|
-
|
|
48110
|
-
|
|
48111
|
-
'
|
|
48112
|
-
|
|
48113
|
-
|
|
48114
|
-
|
|
48115
|
-
|
|
48116
|
-
|
|
48117
|
-
|
|
48118
|
-
|
|
48119
|
-
|
|
48120
|
-
|
|
48121
|
-
|
|
48122
|
-
|
|
48123
|
-
|
|
48124
|
-
|
|
48125
|
-
|
|
48126
|
-
|
|
48127
|
-
|
|
48128
|
-
|
|
48129
|
-
|
|
48130
|
-
|
|
48131
|
-
|
|
48132
|
-
|
|
48133
|
-
|
|
48134
|
-
|
|
48135
|
-
|
|
48136
|
-
|
|
48137
|
-
'
|
|
48138
|
-
|
|
48139
|
-
|
|
48140
|
-
|
|
48141
|
-
|
|
48142
|
-
|
|
48143
|
-
|
|
48144
|
-
|
|
48145
|
-
|
|
48146
|
-
|
|
48147
|
-
|
|
48148
|
-
|
|
48149
|
-
|
|
48150
|
-
|
|
48151
|
-
|
|
48152
|
-
|
|
48153
|
-
|
|
48154
|
-
|
|
48155
|
-
|
|
48156
|
-
|
|
48157
|
-
|
|
48158
|
-
|
|
48159
|
-
|
|
48160
|
-
|
|
48161
|
-
'
|
|
48162
|
-
|
|
48163
|
-
|
|
48164
|
-
|
|
48165
|
-
|
|
48166
|
-
|
|
48167
|
-
|
|
48168
|
-
|
|
48169
|
-
|
|
48170
|
-
|
|
48171
|
-
|
|
48172
|
-
|
|
48173
|
-
|
|
48174
|
-
|
|
48175
|
-
|
|
48176
|
-
|
|
48177
|
-
|
|
48178
|
-
|
|
48179
|
-
|
|
48180
|
-
|
|
48181
|
-
|
|
48182
|
-
|
|
48183
|
-
|
|
48184
|
-
|
|
47913
|
+
const astro_astroConfig = {
|
|
47914
|
+
files: [
|
|
47915
|
+
'astro.config.js',
|
|
47916
|
+
'astro.config.ts',
|
|
47917
|
+
'astro.config.mjs',
|
|
47918
|
+
'astro.config.mts'
|
|
47919
|
+
],
|
|
47920
|
+
plugin: 'zephyr-astro-integration',
|
|
47921
|
+
importName: 'withZephyr',
|
|
47922
|
+
patterns: [
|
|
47923
|
+
{
|
|
47924
|
+
type: 'define-config-function',
|
|
47925
|
+
matcher: /defineConfig\s*\(\s*\(\s*\)\s*=>\s*\(\s*\{/,
|
|
47926
|
+
transform: 'addToAstroIntegrationsInFunctionOrCreate'
|
|
47927
|
+
},
|
|
47928
|
+
{
|
|
47929
|
+
type: 'define-config',
|
|
47930
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
47931
|
+
transform: 'addToAstroIntegrationsOrCreate'
|
|
47932
|
+
},
|
|
47933
|
+
{
|
|
47934
|
+
type: 'export-default',
|
|
47935
|
+
matcher: /export\s+default\s+\{/,
|
|
47936
|
+
transform: 'addToAstroIntegrationsOrCreate'
|
|
47937
|
+
}
|
|
47938
|
+
]
|
|
47939
|
+
};
|
|
47940
|
+
const modernjs_modernjsConfig = {
|
|
47941
|
+
files: [
|
|
47942
|
+
'modern.config.js',
|
|
47943
|
+
'modern.config.ts',
|
|
47944
|
+
'modern.config.mjs'
|
|
47945
|
+
],
|
|
47946
|
+
plugin: 'zephyr-modernjs-plugin',
|
|
47947
|
+
importName: 'withZephyr',
|
|
47948
|
+
patterns: [
|
|
47949
|
+
{
|
|
47950
|
+
type: 'define-config',
|
|
47951
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
47952
|
+
transform: 'addToPluginsArrayOrCreate'
|
|
47953
|
+
},
|
|
47954
|
+
{
|
|
47955
|
+
type: 'plugins-array',
|
|
47956
|
+
matcher: /plugins\s*:\s*\[/,
|
|
47957
|
+
transform: 'addToPluginsArray'
|
|
47958
|
+
}
|
|
47959
|
+
]
|
|
47960
|
+
};
|
|
47961
|
+
const parcel_parcelConfig = {
|
|
47962
|
+
files: [
|
|
47963
|
+
'.parcelrc',
|
|
47964
|
+
'.parcelrc.json'
|
|
47965
|
+
],
|
|
47966
|
+
plugin: 'parcel-reporter-zephyr',
|
|
47967
|
+
importName: null,
|
|
47968
|
+
patterns: [
|
|
47969
|
+
{
|
|
47970
|
+
type: 'parcel-reporters',
|
|
47971
|
+
matcher: /"reporters"\s*:\s*\[/,
|
|
47972
|
+
transform: 'addToParcelReporters'
|
|
47973
|
+
}
|
|
47974
|
+
]
|
|
47975
|
+
};
|
|
47976
|
+
const repack_repackConfig = {
|
|
47977
|
+
files: [
|
|
47978
|
+
'rspack.config.js',
|
|
47979
|
+
'rspack.config.ts',
|
|
47980
|
+
'rspack.config.mjs'
|
|
47981
|
+
],
|
|
47982
|
+
plugin: 'zephyr-repack-plugin',
|
|
47983
|
+
importName: 'withZephyr',
|
|
47984
|
+
patterns: [
|
|
47985
|
+
{
|
|
47986
|
+
type: 'export-conditional-withzephyr',
|
|
47987
|
+
matcher: /export\s+default\s+.*\?\s*withZephyr\s*\(\s*\)\s*\(/,
|
|
47988
|
+
transform: 'skipAlreadyWrapped'
|
|
47989
|
+
},
|
|
47990
|
+
{
|
|
47991
|
+
type: 'export-function-variable',
|
|
47992
|
+
matcher: /export\s+default\s+(\w+)\s*;?\s*$/,
|
|
47993
|
+
transform: 'wrapExportedFunction'
|
|
47994
|
+
},
|
|
47995
|
+
{
|
|
47996
|
+
type: 'const-function-export',
|
|
47997
|
+
matcher: /const\s+\w+\s*=\s*\w+\s*=>/,
|
|
47998
|
+
transform: 'wrapExportedFunction'
|
|
47999
|
+
}
|
|
48000
|
+
]
|
|
48001
|
+
};
|
|
48002
|
+
const rolldown_rolldownConfig = {
|
|
48003
|
+
files: [
|
|
48004
|
+
'rolldown.config.js',
|
|
48005
|
+
'rolldown.config.ts',
|
|
48006
|
+
'rolldown.config.mjs'
|
|
48007
|
+
],
|
|
48008
|
+
plugin: 'zephyr-rolldown-plugin',
|
|
48009
|
+
importName: 'withZephyr',
|
|
48010
|
+
patterns: [
|
|
48011
|
+
{
|
|
48012
|
+
type: 'define-config',
|
|
48013
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
48014
|
+
transform: 'addToPluginsArrayOrCreate'
|
|
48015
|
+
},
|
|
48016
|
+
{
|
|
48017
|
+
type: 'plugins-array',
|
|
48018
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48019
|
+
transform: 'addToPluginsArray'
|
|
48020
|
+
}
|
|
48021
|
+
]
|
|
48022
|
+
};
|
|
48023
|
+
const rollup_rollupConfig = {
|
|
48024
|
+
files: [
|
|
48025
|
+
'rollup.config.js',
|
|
48026
|
+
'rollup.config.ts',
|
|
48027
|
+
'rollup.config.mjs'
|
|
48028
|
+
],
|
|
48029
|
+
plugin: 'rollup-plugin-zephyr',
|
|
48030
|
+
importName: 'withZephyr',
|
|
48031
|
+
patterns: [
|
|
48032
|
+
{
|
|
48033
|
+
type: 'export-array',
|
|
48034
|
+
matcher: /export\s+default\s+\[/,
|
|
48035
|
+
transform: 'addToRollupArrayConfig'
|
|
48036
|
+
},
|
|
48037
|
+
{
|
|
48038
|
+
type: 'module-exports-function',
|
|
48039
|
+
matcher: /module\.exports\s*=\s*\(\s*config\s*\)\s*=>/,
|
|
48040
|
+
transform: 'addToRollupFunction'
|
|
48041
|
+
},
|
|
48042
|
+
{
|
|
48043
|
+
type: 'plugins-array',
|
|
48044
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48045
|
+
transform: 'addToPluginsArray'
|
|
48046
|
+
}
|
|
48047
|
+
]
|
|
48048
|
+
};
|
|
48049
|
+
const rsbuild_rsbuildConfig = {
|
|
48050
|
+
files: [
|
|
48051
|
+
'rsbuild.config.js',
|
|
48052
|
+
'rsbuild.config.ts',
|
|
48053
|
+
'rsbuild.config.mjs'
|
|
48054
|
+
],
|
|
48055
|
+
plugin: 'zephyr-rsbuild-plugin',
|
|
48056
|
+
importName: 'withZephyr',
|
|
48057
|
+
patterns: [
|
|
48058
|
+
{
|
|
48059
|
+
type: 'define-config',
|
|
48060
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
48061
|
+
transform: 'addToPluginsArray'
|
|
48062
|
+
},
|
|
48063
|
+
{
|
|
48064
|
+
type: 'plugins-array',
|
|
48065
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48066
|
+
transform: 'addToPluginsArray'
|
|
48067
|
+
}
|
|
48068
|
+
]
|
|
48069
|
+
};
|
|
48070
|
+
const rslib_rslibConfig = {
|
|
48071
|
+
files: [
|
|
48072
|
+
'rslib.config.js',
|
|
48073
|
+
'rslib.config.ts',
|
|
48074
|
+
'rslib.config.mjs'
|
|
48075
|
+
],
|
|
48076
|
+
plugin: 'zephyr-rsbuild-plugin',
|
|
48077
|
+
importName: 'withZephyr',
|
|
48078
|
+
patterns: [
|
|
48079
|
+
{
|
|
48080
|
+
type: 'define-config',
|
|
48081
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
48082
|
+
transform: 'addToPluginsArray'
|
|
48083
|
+
},
|
|
48084
|
+
{
|
|
48085
|
+
type: 'plugins-array',
|
|
48086
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48087
|
+
transform: 'addToPluginsArray'
|
|
48088
|
+
}
|
|
48089
|
+
]
|
|
48090
|
+
};
|
|
48091
|
+
const rspack_rspackConfig = {
|
|
48092
|
+
files: [
|
|
48093
|
+
'rspack.config.js',
|
|
48094
|
+
'rspack.config.ts',
|
|
48095
|
+
'rspack.config.mjs'
|
|
48096
|
+
],
|
|
48097
|
+
plugin: 'zephyr-rspack-plugin',
|
|
48098
|
+
importName: 'withZephyr',
|
|
48099
|
+
patterns: [
|
|
48100
|
+
{
|
|
48101
|
+
type: 'export-wrapped-call',
|
|
48102
|
+
matcher: /export\s+default\s+withZephyr\s*\(\s*\)\s*\(/,
|
|
48103
|
+
transform: 'skipAlreadyWrapped'
|
|
48104
|
+
},
|
|
48105
|
+
{
|
|
48106
|
+
type: 'compose-plugins',
|
|
48107
|
+
matcher: /composePlugins\s*\(/,
|
|
48108
|
+
transform: 'addToComposePlugins'
|
|
48109
|
+
},
|
|
48110
|
+
{
|
|
48111
|
+
type: 'export-default-object',
|
|
48112
|
+
matcher: /export\s+default\s+\{/,
|
|
48113
|
+
transform: 'wrapExportDefault'
|
|
48114
|
+
},
|
|
48115
|
+
{
|
|
48116
|
+
type: 'plugins-array',
|
|
48117
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48118
|
+
transform: 'addToPluginsArray'
|
|
48119
|
+
},
|
|
48120
|
+
{
|
|
48121
|
+
type: 'module-exports',
|
|
48122
|
+
matcher: /module\.exports\s*=/,
|
|
48123
|
+
transform: 'wrapModuleExports'
|
|
48124
|
+
}
|
|
48125
|
+
]
|
|
48126
|
+
};
|
|
48127
|
+
const rspress_rspressConfig = {
|
|
48128
|
+
files: [
|
|
48129
|
+
'rspress.config.js',
|
|
48130
|
+
'rspress.config.ts',
|
|
48131
|
+
'rspress.config.mjs'
|
|
48132
|
+
],
|
|
48133
|
+
plugin: 'zephyr-rspress-plugin',
|
|
48134
|
+
importName: 'withZephyr',
|
|
48135
|
+
patterns: [
|
|
48136
|
+
{
|
|
48137
|
+
type: 'define-config',
|
|
48138
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
48139
|
+
transform: 'addToPluginsArrayOrCreate'
|
|
48140
|
+
},
|
|
48141
|
+
{
|
|
48142
|
+
type: 'plugins-array',
|
|
48143
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48144
|
+
transform: 'addToPluginsArray'
|
|
48145
|
+
}
|
|
48146
|
+
]
|
|
48147
|
+
};
|
|
48148
|
+
const vite_viteConfig = {
|
|
48149
|
+
files: [
|
|
48150
|
+
'vite.config.js',
|
|
48151
|
+
'vite.config.ts',
|
|
48152
|
+
'vite.config.mjs',
|
|
48153
|
+
'vite.config.mts'
|
|
48154
|
+
],
|
|
48155
|
+
plugin: 'vite-plugin-zephyr',
|
|
48156
|
+
importName: 'withZephyr',
|
|
48157
|
+
patterns: [
|
|
48158
|
+
{
|
|
48159
|
+
type: 'define-config-function',
|
|
48160
|
+
matcher: /defineConfig\s*\(\s*\(\s*\)\s*=>\s*\(\s*\{/,
|
|
48161
|
+
transform: 'addToVitePluginsInFunction'
|
|
48162
|
+
},
|
|
48163
|
+
{
|
|
48164
|
+
type: 'define-config',
|
|
48165
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
48166
|
+
transform: 'addToVitePlugins'
|
|
48167
|
+
},
|
|
48168
|
+
{
|
|
48169
|
+
type: 'export-default',
|
|
48170
|
+
matcher: /export\s+default\s+\{/,
|
|
48171
|
+
transform: 'addToVitePlugins'
|
|
48172
|
+
}
|
|
48173
|
+
]
|
|
48174
|
+
};
|
|
48175
|
+
const webpack_webpackConfig = {
|
|
48176
|
+
files: [
|
|
48177
|
+
'webpack.config.js',
|
|
48178
|
+
'webpack.config.ts',
|
|
48179
|
+
'webpack.config.mjs'
|
|
48180
|
+
],
|
|
48181
|
+
plugin: 'zephyr-webpack-plugin',
|
|
48182
|
+
importName: 'withZephyr',
|
|
48183
|
+
patterns: [
|
|
48184
|
+
{
|
|
48185
|
+
type: 'compose-plugins',
|
|
48186
|
+
matcher: /composePlugins\s*\(/,
|
|
48187
|
+
transform: 'addToComposePlugins'
|
|
48188
|
+
},
|
|
48189
|
+
{
|
|
48190
|
+
type: 'plugins-array',
|
|
48191
|
+
matcher: /plugins\s*:\s*\[/,
|
|
48192
|
+
transform: 'addToPluginsArray'
|
|
48193
|
+
},
|
|
48194
|
+
{
|
|
48195
|
+
type: 'module-exports',
|
|
48196
|
+
matcher: /module\.exports\s*=/,
|
|
48197
|
+
transform: 'wrapModuleExports'
|
|
48198
|
+
}
|
|
48199
|
+
]
|
|
48185
48200
|
};
|
|
48186
48201
|
function detectPackageManager(directory = process.cwd()) {
|
|
48202
|
+
if (process.env.npm_config_user_agent) {
|
|
48203
|
+
const userAgent = process.env.npm_config_user_agent.toLowerCase();
|
|
48204
|
+
if (userAgent.includes('pnpm')) return 'pnpm';
|
|
48205
|
+
if (userAgent.includes('yarn')) return 'yarn';
|
|
48206
|
+
if (userAgent.includes('bun')) return 'bun';
|
|
48207
|
+
if (userAgent.includes('npm')) return 'npm';
|
|
48208
|
+
}
|
|
48187
48209
|
const lockFiles = {
|
|
48188
48210
|
'pnpm-lock.yaml': 'pnpm',
|
|
48189
48211
|
'yarn.lock': 'yarn',
|
|
@@ -48216,12 +48238,6 @@ function detectPackageManager(directory = process.cwd()) {
|
|
|
48216
48238
|
if (fs_0.existsSync(path_0.join(rootDir, 'lerna.json')) || fs_0.existsSync(path_0.join(rootDir, 'yarn.lock')) && rootDir === directory) return 'yarn';
|
|
48217
48239
|
}
|
|
48218
48240
|
} catch {}
|
|
48219
|
-
if (process.env.npm_config_user_agent) {
|
|
48220
|
-
const userAgent = process.env.npm_config_user_agent.toLowerCase();
|
|
48221
|
-
if (userAgent.includes('pnpm')) return 'pnpm';
|
|
48222
|
-
if (userAgent.includes('yarn')) return 'yarn';
|
|
48223
|
-
if (userAgent.includes('bun')) return 'bun';
|
|
48224
|
-
}
|
|
48225
48241
|
return 'npm';
|
|
48226
48242
|
}
|
|
48227
48243
|
function isPackageInstalled(packageName, directory = process.cwd()) {
|
|
@@ -48257,8 +48273,8 @@ function installPackage(directory, packageName, packageManager, isDev = true) {
|
|
|
48257
48273
|
}
|
|
48258
48274
|
}
|
|
48259
48275
|
var lib = __webpack_require__("../../node_modules/.pnpm/@babel+parser@7.28.4/node_modules/@babel/parser/lib/index.js");
|
|
48260
|
-
var traverse_lib = __webpack_require__("../../node_modules/.pnpm/@babel+traverse@7.28.4_supports-color@5.5.0/node_modules/@babel/traverse/lib/index.js");
|
|
48261
48276
|
var generator_lib = __webpack_require__("../../node_modules/.pnpm/@babel+generator@7.28.3/node_modules/@babel/generator/lib/index.js");
|
|
48277
|
+
var traverse_lib = __webpack_require__("../../node_modules/.pnpm/@babel+traverse@7.28.4_supports-color@5.5.0/node_modules/@babel/traverse/lib/index.js");
|
|
48262
48278
|
var types_lib = __webpack_require__("../../node_modules/.pnpm/@babel+types@7.28.4/node_modules/@babel/types/lib/index.js");
|
|
48263
48279
|
function parseFile(filePath) {
|
|
48264
48280
|
const content = fs_0.readFileSync(filePath, 'utf8');
|
|
@@ -48300,6 +48316,18 @@ function writeFile(filePath, ast) {
|
|
|
48300
48316
|
});
|
|
48301
48317
|
fs_0.writeFileSync(filePath, output.code);
|
|
48302
48318
|
}
|
|
48319
|
+
function hasZephyrPlugin(ast) {
|
|
48320
|
+
let hasPlugin = false;
|
|
48321
|
+
(0, traverse_lib["default"])(ast, {
|
|
48322
|
+
CallExpression (path) {
|
|
48323
|
+
if (types_lib.isIdentifier(path.node.callee, {
|
|
48324
|
+
name: 'withZephyr'
|
|
48325
|
+
})) hasPlugin = true;
|
|
48326
|
+
}
|
|
48327
|
+
});
|
|
48328
|
+
return hasPlugin;
|
|
48329
|
+
}
|
|
48330
|
+
function skipAlreadyWrapped(_ast) {}
|
|
48303
48331
|
function addZephyrImport(ast, pluginName, importName) {
|
|
48304
48332
|
if (!importName) return;
|
|
48305
48333
|
let hasImport = false;
|
|
@@ -48348,19 +48376,44 @@ function addZephyrRequire(ast, pluginName, importName) {
|
|
|
48348
48376
|
});
|
|
48349
48377
|
}
|
|
48350
48378
|
}
|
|
48351
|
-
function
|
|
48352
|
-
|
|
48379
|
+
function addToPluginsArray(ast) {
|
|
48380
|
+
(0, traverse_lib["default"])(ast, {
|
|
48381
|
+
ObjectProperty (path) {
|
|
48382
|
+
if (types_lib.isIdentifier(path.node.key, {
|
|
48383
|
+
name: 'plugins'
|
|
48384
|
+
}) && types_lib.isArrayExpression(path.node.value)) path.node.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48385
|
+
}
|
|
48386
|
+
});
|
|
48387
|
+
}
|
|
48388
|
+
function addToPluginsArrayOrCreate(ast) {
|
|
48389
|
+
let pluginAdded = false;
|
|
48353
48390
|
(0, traverse_lib["default"])(ast, {
|
|
48354
48391
|
CallExpression (path) {
|
|
48355
48392
|
if (types_lib.isIdentifier(path.node.callee, {
|
|
48356
|
-
name: '
|
|
48357
|
-
})
|
|
48358
|
-
|
|
48359
|
-
|
|
48360
|
-
|
|
48393
|
+
name: 'defineConfig'
|
|
48394
|
+
}) && 1 === path.node.arguments.length && types_lib.isObjectExpression(path.node.arguments[0])) {
|
|
48395
|
+
const configObject = path.node.arguments[0];
|
|
48396
|
+
let pluginsProperty = null;
|
|
48397
|
+
for (const prop of configObject.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48398
|
+
name: 'plugins'
|
|
48399
|
+
}) && types_lib.isArrayExpression(prop.value)) {
|
|
48400
|
+
pluginsProperty = prop;
|
|
48401
|
+
break;
|
|
48402
|
+
}
|
|
48403
|
+
if (pluginsProperty && types_lib.isArrayExpression(pluginsProperty.value)) {
|
|
48404
|
+
pluginsProperty.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48405
|
+
pluginAdded = true;
|
|
48406
|
+
} else if (!pluginsProperty) {
|
|
48407
|
+
const newPluginsProperty = types_lib.objectProperty(types_lib.identifier('plugins'), types_lib.arrayExpression([
|
|
48408
|
+
types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48409
|
+
]));
|
|
48410
|
+
configObject.properties.push(newPluginsProperty);
|
|
48411
|
+
pluginAdded = true;
|
|
48412
|
+
}
|
|
48413
|
+
}
|
|
48361
48414
|
}
|
|
48362
48415
|
});
|
|
48363
|
-
|
|
48416
|
+
if (!pluginAdded) addToPluginsArray(ast);
|
|
48364
48417
|
}
|
|
48365
48418
|
function addToComposePlugins(ast) {
|
|
48366
48419
|
(0, traverse_lib["default"])(ast, {
|
|
@@ -48376,15 +48429,6 @@ function addToComposePlugins(ast) {
|
|
|
48376
48429
|
}
|
|
48377
48430
|
});
|
|
48378
48431
|
}
|
|
48379
|
-
function addToPluginsArray(ast) {
|
|
48380
|
-
(0, traverse_lib["default"])(ast, {
|
|
48381
|
-
ObjectProperty (path) {
|
|
48382
|
-
if (types_lib.isIdentifier(path.node.key, {
|
|
48383
|
-
name: 'plugins'
|
|
48384
|
-
}) && types_lib.isArrayExpression(path.node.value)) path.node.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48385
|
-
}
|
|
48386
|
-
});
|
|
48387
|
-
}
|
|
48388
48432
|
function addToVitePlugins(ast) {
|
|
48389
48433
|
addToPluginsArray(ast);
|
|
48390
48434
|
}
|
|
@@ -48410,13 +48454,112 @@ function addToVitePluginsInFunction(ast) {
|
|
|
48410
48454
|
}
|
|
48411
48455
|
});
|
|
48412
48456
|
}
|
|
48457
|
+
function addToAstroIntegrations(ast) {
|
|
48458
|
+
(0, traverse_lib["default"])(ast, {
|
|
48459
|
+
ObjectExpression (path) {
|
|
48460
|
+
for (const prop of path.node.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48461
|
+
name: 'integrations'
|
|
48462
|
+
}) && types_lib.isArrayExpression(prop.value)) {
|
|
48463
|
+
prop.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48464
|
+
path.stop();
|
|
48465
|
+
return;
|
|
48466
|
+
}
|
|
48467
|
+
}
|
|
48468
|
+
});
|
|
48469
|
+
}
|
|
48470
|
+
function addToAstroIntegrationsInFunction(ast) {
|
|
48471
|
+
(0, traverse_lib["default"])(ast, {
|
|
48472
|
+
CallExpression (path) {
|
|
48473
|
+
if (types_lib.isIdentifier(path.node.callee, {
|
|
48474
|
+
name: 'defineConfig'
|
|
48475
|
+
}) && 1 === path.node.arguments.length && types_lib.isArrowFunctionExpression(path.node.arguments[0])) {
|
|
48476
|
+
const arrowFunc = path.node.arguments[0];
|
|
48477
|
+
let objExpr = null;
|
|
48478
|
+
if (types_lib.isParenthesizedExpression(arrowFunc.body) && types_lib.isObjectExpression(arrowFunc.body.expression)) objExpr = arrowFunc.body.expression;
|
|
48479
|
+
else if (types_lib.isObjectExpression(arrowFunc.body)) objExpr = arrowFunc.body;
|
|
48480
|
+
if (objExpr) {
|
|
48481
|
+
for (const prop of objExpr.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48482
|
+
name: 'integrations'
|
|
48483
|
+
}) && types_lib.isArrayExpression(prop.value)) {
|
|
48484
|
+
prop.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48485
|
+
break;
|
|
48486
|
+
}
|
|
48487
|
+
}
|
|
48488
|
+
}
|
|
48489
|
+
}
|
|
48490
|
+
});
|
|
48491
|
+
}
|
|
48492
|
+
function addToAstroIntegrationsOrCreate(ast) {
|
|
48493
|
+
let integrationAdded = false;
|
|
48494
|
+
(0, traverse_lib["default"])(ast, {
|
|
48495
|
+
CallExpression (path) {
|
|
48496
|
+
if (types_lib.isIdentifier(path.node.callee, {
|
|
48497
|
+
name: 'defineConfig'
|
|
48498
|
+
}) && 1 === path.node.arguments.length && types_lib.isObjectExpression(path.node.arguments[0])) {
|
|
48499
|
+
const configObject = path.node.arguments[0];
|
|
48500
|
+
let integrationsProperty = null;
|
|
48501
|
+
for (const prop of configObject.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48502
|
+
name: 'integrations'
|
|
48503
|
+
}) && types_lib.isArrayExpression(prop.value)) {
|
|
48504
|
+
integrationsProperty = prop;
|
|
48505
|
+
break;
|
|
48506
|
+
}
|
|
48507
|
+
if (integrationsProperty && types_lib.isArrayExpression(integrationsProperty.value)) {
|
|
48508
|
+
integrationsProperty.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48509
|
+
integrationAdded = true;
|
|
48510
|
+
} else if (!integrationsProperty) {
|
|
48511
|
+
const newIntegrationsProperty = types_lib.objectProperty(types_lib.identifier('integrations'), types_lib.arrayExpression([
|
|
48512
|
+
types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48513
|
+
]));
|
|
48514
|
+
configObject.properties.push(newIntegrationsProperty);
|
|
48515
|
+
integrationAdded = true;
|
|
48516
|
+
}
|
|
48517
|
+
}
|
|
48518
|
+
}
|
|
48519
|
+
});
|
|
48520
|
+
if (!integrationAdded) addToAstroIntegrations(ast);
|
|
48521
|
+
}
|
|
48522
|
+
function addToAstroIntegrationsInFunctionOrCreate(ast) {
|
|
48523
|
+
let integrationAdded = false;
|
|
48524
|
+
(0, traverse_lib["default"])(ast, {
|
|
48525
|
+
CallExpression (path) {
|
|
48526
|
+
if (types_lib.isIdentifier(path.node.callee, {
|
|
48527
|
+
name: 'defineConfig'
|
|
48528
|
+
}) && 1 === path.node.arguments.length && types_lib.isArrowFunctionExpression(path.node.arguments[0])) {
|
|
48529
|
+
const arrowFunc = path.node.arguments[0];
|
|
48530
|
+
let objExpr = null;
|
|
48531
|
+
if (types_lib.isParenthesizedExpression(arrowFunc.body) && types_lib.isObjectExpression(arrowFunc.body.expression)) objExpr = arrowFunc.body.expression;
|
|
48532
|
+
else if (types_lib.isObjectExpression(arrowFunc.body)) objExpr = arrowFunc.body;
|
|
48533
|
+
if (objExpr) {
|
|
48534
|
+
let integrationsProperty = null;
|
|
48535
|
+
for (const prop of objExpr.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48536
|
+
name: 'integrations'
|
|
48537
|
+
}) && types_lib.isArrayExpression(prop.value)) {
|
|
48538
|
+
integrationsProperty = prop;
|
|
48539
|
+
break;
|
|
48540
|
+
}
|
|
48541
|
+
if (integrationsProperty && types_lib.isArrayExpression(integrationsProperty.value)) {
|
|
48542
|
+
integrationsProperty.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48543
|
+
integrationAdded = true;
|
|
48544
|
+
} else if (!integrationsProperty) {
|
|
48545
|
+
const newIntegrationsProperty = types_lib.objectProperty(types_lib.identifier('integrations'), types_lib.arrayExpression([
|
|
48546
|
+
types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48547
|
+
]));
|
|
48548
|
+
objExpr.properties.push(newIntegrationsProperty);
|
|
48549
|
+
integrationAdded = true;
|
|
48550
|
+
}
|
|
48551
|
+
}
|
|
48552
|
+
}
|
|
48553
|
+
}
|
|
48554
|
+
});
|
|
48555
|
+
if (!integrationAdded) addToAstroIntegrationsInFunction(ast);
|
|
48556
|
+
}
|
|
48413
48557
|
function addToRollupFunction(ast) {
|
|
48414
48558
|
(0, traverse_lib["default"])(ast, {
|
|
48415
48559
|
ArrowFunctionExpression (path) {
|
|
48416
|
-
if (1 === path.node.params.length && types_lib.isIdentifier(path.node.params[0]
|
|
48417
|
-
name
|
|
48418
|
-
|
|
48419
|
-
const pushStatement = types_lib.expressionStatement(types_lib.callExpression(types_lib.memberExpression(types_lib.memberExpression(types_lib.identifier('config'), types_lib.identifier('plugins')), types_lib.identifier('push')), [
|
|
48560
|
+
if (1 === path.node.params.length && types_lib.isIdentifier(path.node.params[0])) {
|
|
48561
|
+
const paramName = path.node.params[0].name;
|
|
48562
|
+
const pushStatement = types_lib.expressionStatement(types_lib.callExpression(types_lib.memberExpression(types_lib.memberExpression(types_lib.identifier(paramName), types_lib.identifier('plugins')), types_lib.identifier('push')), [
|
|
48420
48563
|
types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48421
48564
|
]));
|
|
48422
48565
|
if (types_lib.isBlockStatement(path.node.body)) {
|
|
@@ -48428,21 +48571,18 @@ function addToRollupFunction(ast) {
|
|
|
48428
48571
|
}
|
|
48429
48572
|
});
|
|
48430
48573
|
}
|
|
48431
|
-
function
|
|
48432
|
-
|
|
48433
|
-
|
|
48434
|
-
|
|
48435
|
-
|
|
48436
|
-
|
|
48437
|
-
|
|
48438
|
-
|
|
48439
|
-
}
|
|
48440
|
-
|
|
48441
|
-
|
|
48442
|
-
|
|
48443
|
-
if (!config.reporters) config.reporters = [];
|
|
48444
|
-
if (!config.reporters.includes(pluginName)) config.reporters.push(pluginName);
|
|
48445
|
-
fs_0.writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
48574
|
+
function addToRollupArrayConfig(ast) {
|
|
48575
|
+
(0, traverse_lib["default"])(ast, {
|
|
48576
|
+
ExportDefaultDeclaration (path) {
|
|
48577
|
+
if (types_lib.isArrayExpression(path.node.declaration)) {
|
|
48578
|
+
for (const element of path.node.declaration.elements)if (types_lib.isObjectExpression(element)) {
|
|
48579
|
+
for (const prop of element.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48580
|
+
name: 'plugins'
|
|
48581
|
+
}) && types_lib.isArrayExpression(prop.value)) return void prop.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48582
|
+
}
|
|
48583
|
+
}
|
|
48584
|
+
}
|
|
48585
|
+
});
|
|
48446
48586
|
}
|
|
48447
48587
|
function wrapModuleExports(ast) {
|
|
48448
48588
|
(0, traverse_lib["default"])(ast, {
|
|
@@ -48451,7 +48591,9 @@ function wrapModuleExports(ast) {
|
|
|
48451
48591
|
name: 'module'
|
|
48452
48592
|
}) && types_lib.isIdentifier(path.node.left.property, {
|
|
48453
48593
|
name: 'exports'
|
|
48454
|
-
})) path.node.right = types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48594
|
+
})) path.node.right = types_lib.callExpression(types_lib.callExpression(types_lib.identifier('withZephyr'), []), [
|
|
48595
|
+
path.node.right
|
|
48596
|
+
]);
|
|
48455
48597
|
}
|
|
48456
48598
|
});
|
|
48457
48599
|
}
|
|
@@ -48464,20 +48606,6 @@ function wrapExportDefault(ast) {
|
|
|
48464
48606
|
}
|
|
48465
48607
|
});
|
|
48466
48608
|
}
|
|
48467
|
-
function addToRollupArrayConfig(ast) {
|
|
48468
|
-
(0, traverse_lib["default"])(ast, {
|
|
48469
|
-
ExportDefaultDeclaration (path) {
|
|
48470
|
-
if (types_lib.isArrayExpression(path.node.declaration)) {
|
|
48471
|
-
for (const element of path.node.declaration.elements)if (types_lib.isObjectExpression(element)) {
|
|
48472
|
-
for (const prop of element.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48473
|
-
name: 'plugins'
|
|
48474
|
-
}) && types_lib.isArrayExpression(prop.value)) return void prop.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48475
|
-
}
|
|
48476
|
-
}
|
|
48477
|
-
}
|
|
48478
|
-
});
|
|
48479
|
-
}
|
|
48480
|
-
function skipAlreadyWrapped(_ast) {}
|
|
48481
48609
|
function wrapExportedFunction(ast) {
|
|
48482
48610
|
(0, traverse_lib["default"])(ast, {
|
|
48483
48611
|
ExportDefaultDeclaration (path) {
|
|
@@ -48498,122 +48626,50 @@ function wrapExportedFunction(ast) {
|
|
|
48498
48626
|
}
|
|
48499
48627
|
});
|
|
48500
48628
|
}
|
|
48501
|
-
function
|
|
48502
|
-
|
|
48503
|
-
(
|
|
48504
|
-
|
|
48505
|
-
|
|
48506
|
-
|
|
48507
|
-
for (const spec of specifiers)if (types_lib.isImportSpecifier(spec) && types_lib.isIdentifier(spec.imported, {
|
|
48508
|
-
name: 'withZephyr'
|
|
48509
|
-
})) hasWithZephyrImport = true;
|
|
48510
|
-
}
|
|
48511
|
-
}
|
|
48512
|
-
});
|
|
48513
|
-
if (!hasWithZephyrImport) {
|
|
48514
|
-
const importDeclaration = types_lib.importDeclaration([
|
|
48515
|
-
types_lib.importSpecifier(types_lib.identifier('withZephyr'), types_lib.identifier('withZephyr'))
|
|
48516
|
-
], types_lib.stringLiteral('zephyr-rspack-plugin'));
|
|
48517
|
-
(0, traverse_lib["default"])(ast, {
|
|
48518
|
-
Program (path) {
|
|
48519
|
-
const firstImportIndex = path.node.body.findIndex((node)=>types_lib.isImportDeclaration(node));
|
|
48520
|
-
if (firstImportIndex >= 0) path.node.body.splice(firstImportIndex + 1, 0, importDeclaration);
|
|
48521
|
-
else path.node.body.unshift(importDeclaration);
|
|
48522
|
-
path.stop();
|
|
48523
|
-
}
|
|
48524
|
-
});
|
|
48525
|
-
}
|
|
48526
|
-
let hasZephyrPlugin = false;
|
|
48527
|
-
(0, traverse_lib["default"])(ast, {
|
|
48528
|
-
VariableDeclarator (path) {
|
|
48529
|
-
if (types_lib.isIdentifier(path.node.id, {
|
|
48530
|
-
name: 'zephyrRSbuildPlugin'
|
|
48531
|
-
})) hasZephyrPlugin = true;
|
|
48532
|
-
}
|
|
48533
|
-
});
|
|
48534
|
-
if (!hasZephyrPlugin) {
|
|
48535
|
-
const zephyrPluginFunction = types_lib.variableDeclaration('const', [
|
|
48536
|
-
types_lib.variableDeclarator(types_lib.identifier('zephyrRSbuildPlugin'), types_lib.arrowFunctionExpression([], types_lib.objectExpression([
|
|
48537
|
-
types_lib.objectProperty(types_lib.identifier('name'), types_lib.stringLiteral('zephyr-rsbuild-plugin')),
|
|
48538
|
-
types_lib.objectMethod('method', types_lib.identifier('setup'), [
|
|
48539
|
-
types_lib.identifier('api')
|
|
48540
|
-
], types_lib.blockStatement([
|
|
48541
|
-
types_lib.expressionStatement(types_lib.callExpression(types_lib.memberExpression(types_lib.identifier('api'), types_lib.identifier('modifyRspackConfig')), [
|
|
48542
|
-
types_lib.arrowFunctionExpression([
|
|
48543
|
-
types_lib.identifier('config')
|
|
48544
|
-
], types_lib.blockStatement([
|
|
48545
|
-
types_lib.variableDeclaration('const', [
|
|
48546
|
-
types_lib.variableDeclarator(types_lib.identifier('zephyrConfig'), types_lib.awaitExpression(types_lib.callExpression(types_lib.callExpression(types_lib.identifier('withZephyr'), []), [
|
|
48547
|
-
types_lib.identifier('config')
|
|
48548
|
-
])))
|
|
48549
|
-
]),
|
|
48550
|
-
types_lib.expressionStatement(types_lib.assignmentExpression('=', types_lib.identifier('config'), types_lib.identifier('zephyrConfig')))
|
|
48551
|
-
]), true)
|
|
48552
|
-
]))
|
|
48553
|
-
]))
|
|
48554
|
-
])))
|
|
48555
|
-
]);
|
|
48556
|
-
(0, traverse_lib["default"])(ast, {
|
|
48557
|
-
Program (path) {
|
|
48558
|
-
let insertIndex = 0;
|
|
48559
|
-
for(let i = 0; i < path.node.body.length; i++)if (types_lib.isImportDeclaration(path.node.body[i])) insertIndex = i + 1;
|
|
48560
|
-
else break;
|
|
48561
|
-
path.node.body.splice(insertIndex, 0, zephyrPluginFunction);
|
|
48562
|
-
path.stop();
|
|
48563
|
-
}
|
|
48564
|
-
});
|
|
48565
|
-
let hasRsbuildPluginImport = false;
|
|
48566
|
-
(0, traverse_lib["default"])(ast, {
|
|
48567
|
-
ImportDeclaration (path) {
|
|
48568
|
-
if ('@rsbuild/core' === path.node.source.value) {
|
|
48569
|
-
const specifiers = path.node.specifiers;
|
|
48570
|
-
for (const spec of specifiers)if (types_lib.isImportSpecifier(spec) && types_lib.isIdentifier(spec.imported, {
|
|
48571
|
-
name: 'RsbuildPlugin'
|
|
48572
|
-
})) hasRsbuildPluginImport = true;
|
|
48573
|
-
if (!hasRsbuildPluginImport) specifiers.push(types_lib.importSpecifier(types_lib.identifier('RsbuildPlugin'), types_lib.identifier('RsbuildPlugin')));
|
|
48574
|
-
}
|
|
48575
|
-
}
|
|
48576
|
-
});
|
|
48577
|
-
}
|
|
48578
|
-
(0, traverse_lib["default"])(ast, {
|
|
48579
|
-
ObjectProperty (path) {
|
|
48580
|
-
if (types_lib.isIdentifier(path.node.key, {
|
|
48581
|
-
name: 'plugins'
|
|
48582
|
-
}) && types_lib.isArrayExpression(path.node.value)) {
|
|
48583
|
-
let hasZephyrInPlugins = false;
|
|
48584
|
-
for (const element of path.node.value.elements)if (types_lib.isCallExpression(element) && types_lib.isIdentifier(element.callee, {
|
|
48585
|
-
name: 'zephyrRSbuildPlugin'
|
|
48586
|
-
})) {
|
|
48587
|
-
hasZephyrInPlugins = true;
|
|
48588
|
-
break;
|
|
48589
|
-
}
|
|
48590
|
-
if (!hasZephyrInPlugins) path.node.value.elements.push(types_lib.callExpression(types_lib.identifier('zephyrRSbuildPlugin'), []));
|
|
48591
|
-
}
|
|
48592
|
-
}
|
|
48593
|
-
});
|
|
48629
|
+
function addToParcelReporters(filePath, pluginName) {
|
|
48630
|
+
const content = fs_0.readFileSync(filePath, 'utf8');
|
|
48631
|
+
const config = JSON.parse(content);
|
|
48632
|
+
if (!config.reporters) config.reporters = [];
|
|
48633
|
+
if (!config.reporters.includes(pluginName)) config.reporters.push(pluginName);
|
|
48634
|
+
fs_0.writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
48594
48635
|
}
|
|
48636
|
+
const src_BUNDLER_CONFIGS = {
|
|
48637
|
+
webpack: webpack_webpackConfig,
|
|
48638
|
+
rspack: rspack_rspackConfig,
|
|
48639
|
+
vite: vite_viteConfig,
|
|
48640
|
+
rollup: rollup_rollupConfig,
|
|
48641
|
+
rolldown: rolldown_rolldownConfig,
|
|
48642
|
+
rsbuild: rsbuild_rsbuildConfig,
|
|
48643
|
+
rslib: rslib_rslibConfig,
|
|
48644
|
+
parcel: parcel_parcelConfig,
|
|
48645
|
+
astro: astro_astroConfig,
|
|
48646
|
+
modernjs: modernjs_modernjsConfig,
|
|
48647
|
+
rspress: rspress_rspressConfig,
|
|
48648
|
+
repack: repack_repackConfig
|
|
48649
|
+
};
|
|
48595
48650
|
const TRANSFORMERS = {
|
|
48596
48651
|
addToComposePlugins: addToComposePlugins,
|
|
48597
48652
|
addToPluginsArray: addToPluginsArray,
|
|
48653
|
+
addToPluginsArrayOrCreate: addToPluginsArrayOrCreate,
|
|
48598
48654
|
addToVitePlugins: addToVitePlugins,
|
|
48599
48655
|
addToVitePluginsInFunction: addToVitePluginsInFunction,
|
|
48656
|
+
addToAstroIntegrations: addToAstroIntegrations,
|
|
48657
|
+
addToAstroIntegrationsInFunction: addToAstroIntegrationsInFunction,
|
|
48658
|
+
addToAstroIntegrationsOrCreate: addToAstroIntegrationsOrCreate,
|
|
48659
|
+
addToAstroIntegrationsInFunctionOrCreate: addToAstroIntegrationsInFunctionOrCreate,
|
|
48600
48660
|
addToRollupFunction: addToRollupFunction,
|
|
48601
48661
|
addToRollupArrayConfig: addToRollupArrayConfig,
|
|
48602
|
-
addToRolldownPlugins: addToRolldownPlugins,
|
|
48603
|
-
addToModernJSPlugins: addToModernJSPlugins,
|
|
48604
|
-
addToRSPressPlugins: addToRSPressPlugins,
|
|
48605
48662
|
wrapModuleExports: wrapModuleExports,
|
|
48606
48663
|
wrapExportDefault: wrapExportDefault,
|
|
48607
48664
|
skipAlreadyWrapped: skipAlreadyWrapped,
|
|
48608
|
-
wrapExportedFunction: wrapExportedFunction
|
|
48609
|
-
addZephyrRSbuildPlugin: addZephyrRSbuildPlugin
|
|
48665
|
+
wrapExportedFunction: wrapExportedFunction
|
|
48610
48666
|
};
|
|
48611
48667
|
function normalizePathForOutput(filePath) {
|
|
48612
48668
|
return filePath.replace(/\\/g, '/');
|
|
48613
48669
|
}
|
|
48614
48670
|
function findConfigFiles(directory) {
|
|
48615
48671
|
const configFiles = [];
|
|
48616
|
-
for (const [bundlerName, config] of Object.entries(
|
|
48672
|
+
for (const [bundlerName, config] of Object.entries(src_BUNDLER_CONFIGS))for (const fileName of config.files){
|
|
48617
48673
|
const pattern = `${directory}/**/${fileName}`.replace(/\\/g, '/');
|
|
48618
48674
|
const matches = esm_glob.sync(pattern, {
|
|
48619
48675
|
ignore: [
|
|
@@ -48656,7 +48712,7 @@ function checkHasZephyr(filePath, config) {
|
|
|
48656
48712
|
}
|
|
48657
48713
|
{
|
|
48658
48714
|
const ast = parseFile(filePath);
|
|
48659
|
-
return
|
|
48715
|
+
return hasZephyrPlugin(ast);
|
|
48660
48716
|
}
|
|
48661
48717
|
} catch (error) {
|
|
48662
48718
|
console.warn(source.yellow(`Warning: Could not parse ${normalizePathForOutput(filePath)}: ${error.message}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "with-zephyr",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-next.2",
|
|
4
4
|
"description": "A codemod to automatically add withZephyr plugin to bundler configurations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/node": "^24.5.2",
|
|
39
39
|
"@rslib/core": "^0.13.3",
|
|
40
40
|
"typescript": "^5.9.2",
|
|
41
|
-
"zephyr-rsbuild-plugin": "0.1.
|
|
41
|
+
"zephyr-rsbuild-plugin": "0.1.1-next.2"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"zephyr",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"rspack",
|
|
51
51
|
"rsbuild",
|
|
52
52
|
"rslib",
|
|
53
|
+
"astro",
|
|
53
54
|
"modernjs",
|
|
54
55
|
"rolldown",
|
|
55
56
|
"rspress"
|