with-zephyr 0.0.0-canary.5 → 0.0.0-canary.8
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 +411 -318
- 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,268 +47910,293 @@ 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
|
-
|
|
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: 'addToAstroIntegrationsInFunction'
|
|
47927
|
+
},
|
|
47928
|
+
{
|
|
47929
|
+
type: 'define-config',
|
|
47930
|
+
matcher: /defineConfig\s*\(\s*\{/,
|
|
47931
|
+
transform: 'addToAstroIntegrations'
|
|
47932
|
+
},
|
|
47933
|
+
{
|
|
47934
|
+
type: 'export-default',
|
|
47935
|
+
matcher: /export\s+default\s+\{/,
|
|
47936
|
+
transform: 'addToAstroIntegrations'
|
|
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
|
+
]
|
|
48175
48200
|
};
|
|
48176
48201
|
function detectPackageManager(directory = process.cwd()) {
|
|
48177
48202
|
if (process.env.npm_config_user_agent) {
|
|
@@ -48248,8 +48273,8 @@ function installPackage(directory, packageName, packageManager, isDev = true) {
|
|
|
48248
48273
|
}
|
|
48249
48274
|
}
|
|
48250
48275
|
var lib = __webpack_require__("../../node_modules/.pnpm/@babel+parser@7.28.4/node_modules/@babel/parser/lib/index.js");
|
|
48251
|
-
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");
|
|
48252
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");
|
|
48253
48278
|
var types_lib = __webpack_require__("../../node_modules/.pnpm/@babel+types@7.28.4/node_modules/@babel/types/lib/index.js");
|
|
48254
48279
|
function parseFile(filePath) {
|
|
48255
48280
|
const content = fs_0.readFileSync(filePath, 'utf8');
|
|
@@ -48291,6 +48316,18 @@ function writeFile(filePath, ast) {
|
|
|
48291
48316
|
});
|
|
48292
48317
|
fs_0.writeFileSync(filePath, output.code);
|
|
48293
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) {}
|
|
48294
48331
|
function addZephyrImport(ast, pluginName, importName) {
|
|
48295
48332
|
if (!importName) return;
|
|
48296
48333
|
let hasImport = false;
|
|
@@ -48339,19 +48376,44 @@ function addZephyrRequire(ast, pluginName, importName) {
|
|
|
48339
48376
|
});
|
|
48340
48377
|
}
|
|
48341
48378
|
}
|
|
48342
|
-
function
|
|
48343
|
-
|
|
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;
|
|
48344
48390
|
(0, traverse_lib["default"])(ast, {
|
|
48345
48391
|
CallExpression (path) {
|
|
48346
48392
|
if (types_lib.isIdentifier(path.node.callee, {
|
|
48347
|
-
name: '
|
|
48348
|
-
})
|
|
48349
|
-
|
|
48350
|
-
|
|
48351
|
-
|
|
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
|
+
}
|
|
48352
48414
|
}
|
|
48353
48415
|
});
|
|
48354
|
-
|
|
48416
|
+
if (!pluginAdded) addToPluginsArray(ast);
|
|
48355
48417
|
}
|
|
48356
48418
|
function addToComposePlugins(ast) {
|
|
48357
48419
|
(0, traverse_lib["default"])(ast, {
|
|
@@ -48367,15 +48429,6 @@ function addToComposePlugins(ast) {
|
|
|
48367
48429
|
}
|
|
48368
48430
|
});
|
|
48369
48431
|
}
|
|
48370
|
-
function addToPluginsArray(ast) {
|
|
48371
|
-
(0, traverse_lib["default"])(ast, {
|
|
48372
|
-
ObjectProperty (path) {
|
|
48373
|
-
if (types_lib.isIdentifier(path.node.key, {
|
|
48374
|
-
name: 'plugins'
|
|
48375
|
-
}) && types_lib.isArrayExpression(path.node.value)) path.node.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48376
|
-
}
|
|
48377
|
-
});
|
|
48378
|
-
}
|
|
48379
48432
|
function addToVitePlugins(ast) {
|
|
48380
48433
|
addToPluginsArray(ast);
|
|
48381
48434
|
}
|
|
@@ -48401,13 +48454,47 @@ function addToVitePluginsInFunction(ast) {
|
|
|
48401
48454
|
}
|
|
48402
48455
|
});
|
|
48403
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
|
+
}
|
|
48404
48492
|
function addToRollupFunction(ast) {
|
|
48405
48493
|
(0, traverse_lib["default"])(ast, {
|
|
48406
48494
|
ArrowFunctionExpression (path) {
|
|
48407
|
-
if (1 === path.node.params.length && types_lib.isIdentifier(path.node.params[0]
|
|
48408
|
-
name
|
|
48409
|
-
|
|
48410
|
-
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')), [
|
|
48495
|
+
if (1 === path.node.params.length && types_lib.isIdentifier(path.node.params[0])) {
|
|
48496
|
+
const paramName = path.node.params[0].name;
|
|
48497
|
+
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')), [
|
|
48411
48498
|
types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48412
48499
|
]));
|
|
48413
48500
|
if (types_lib.isBlockStatement(path.node.body)) {
|
|
@@ -48419,21 +48506,18 @@ function addToRollupFunction(ast) {
|
|
|
48419
48506
|
}
|
|
48420
48507
|
});
|
|
48421
48508
|
}
|
|
48422
|
-
function
|
|
48423
|
-
|
|
48424
|
-
|
|
48425
|
-
|
|
48426
|
-
|
|
48427
|
-
|
|
48428
|
-
|
|
48429
|
-
|
|
48430
|
-
}
|
|
48431
|
-
|
|
48432
|
-
|
|
48433
|
-
|
|
48434
|
-
if (!config.reporters) config.reporters = [];
|
|
48435
|
-
if (!config.reporters.includes(pluginName)) config.reporters.push(pluginName);
|
|
48436
|
-
fs_0.writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
48509
|
+
function addToRollupArrayConfig(ast) {
|
|
48510
|
+
(0, traverse_lib["default"])(ast, {
|
|
48511
|
+
ExportDefaultDeclaration (path) {
|
|
48512
|
+
if (types_lib.isArrayExpression(path.node.declaration)) {
|
|
48513
|
+
for (const element of path.node.declaration.elements)if (types_lib.isObjectExpression(element)) {
|
|
48514
|
+
for (const prop of element.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48515
|
+
name: 'plugins'
|
|
48516
|
+
}) && types_lib.isArrayExpression(prop.value)) return void prop.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48517
|
+
}
|
|
48518
|
+
}
|
|
48519
|
+
}
|
|
48520
|
+
});
|
|
48437
48521
|
}
|
|
48438
48522
|
function wrapModuleExports(ast) {
|
|
48439
48523
|
(0, traverse_lib["default"])(ast, {
|
|
@@ -48442,7 +48526,9 @@ function wrapModuleExports(ast) {
|
|
|
48442
48526
|
name: 'module'
|
|
48443
48527
|
}) && types_lib.isIdentifier(path.node.left.property, {
|
|
48444
48528
|
name: 'exports'
|
|
48445
|
-
})) path.node.right = types_lib.callExpression(types_lib.identifier('withZephyr'), [])
|
|
48529
|
+
})) path.node.right = types_lib.callExpression(types_lib.callExpression(types_lib.identifier('withZephyr'), []), [
|
|
48530
|
+
path.node.right
|
|
48531
|
+
]);
|
|
48446
48532
|
}
|
|
48447
48533
|
});
|
|
48448
48534
|
}
|
|
@@ -48455,20 +48541,6 @@ function wrapExportDefault(ast) {
|
|
|
48455
48541
|
}
|
|
48456
48542
|
});
|
|
48457
48543
|
}
|
|
48458
|
-
function addToRollupArrayConfig(ast) {
|
|
48459
|
-
(0, traverse_lib["default"])(ast, {
|
|
48460
|
-
ExportDefaultDeclaration (path) {
|
|
48461
|
-
if (types_lib.isArrayExpression(path.node.declaration)) {
|
|
48462
|
-
for (const element of path.node.declaration.elements)if (types_lib.isObjectExpression(element)) {
|
|
48463
|
-
for (const prop of element.properties)if (types_lib.isObjectProperty(prop) && types_lib.isIdentifier(prop.key, {
|
|
48464
|
-
name: 'plugins'
|
|
48465
|
-
}) && types_lib.isArrayExpression(prop.value)) return void prop.value.elements.push(types_lib.callExpression(types_lib.identifier('withZephyr'), []));
|
|
48466
|
-
}
|
|
48467
|
-
}
|
|
48468
|
-
}
|
|
48469
|
-
});
|
|
48470
|
-
}
|
|
48471
|
-
function skipAlreadyWrapped(_ast) {}
|
|
48472
48544
|
function wrapExportedFunction(ast) {
|
|
48473
48545
|
(0, traverse_lib["default"])(ast, {
|
|
48474
48546
|
ExportDefaultDeclaration (path) {
|
|
@@ -48489,16 +48561,37 @@ function wrapExportedFunction(ast) {
|
|
|
48489
48561
|
}
|
|
48490
48562
|
});
|
|
48491
48563
|
}
|
|
48564
|
+
function addToParcelReporters(filePath, pluginName) {
|
|
48565
|
+
const content = fs_0.readFileSync(filePath, 'utf8');
|
|
48566
|
+
const config = JSON.parse(content);
|
|
48567
|
+
if (!config.reporters) config.reporters = [];
|
|
48568
|
+
if (!config.reporters.includes(pluginName)) config.reporters.push(pluginName);
|
|
48569
|
+
fs_0.writeFileSync(filePath, JSON.stringify(config, null, 2));
|
|
48570
|
+
}
|
|
48571
|
+
const src_BUNDLER_CONFIGS = {
|
|
48572
|
+
webpack: webpack_webpackConfig,
|
|
48573
|
+
rspack: rspack_rspackConfig,
|
|
48574
|
+
vite: vite_viteConfig,
|
|
48575
|
+
rollup: rollup_rollupConfig,
|
|
48576
|
+
rolldown: rolldown_rolldownConfig,
|
|
48577
|
+
rsbuild: rsbuild_rsbuildConfig,
|
|
48578
|
+
rslib: rslib_rslibConfig,
|
|
48579
|
+
parcel: parcel_parcelConfig,
|
|
48580
|
+
astro: astro_astroConfig,
|
|
48581
|
+
modernjs: modernjs_modernjsConfig,
|
|
48582
|
+
rspress: rspress_rspressConfig,
|
|
48583
|
+
repack: repack_repackConfig
|
|
48584
|
+
};
|
|
48492
48585
|
const TRANSFORMERS = {
|
|
48493
48586
|
addToComposePlugins: addToComposePlugins,
|
|
48494
48587
|
addToPluginsArray: addToPluginsArray,
|
|
48588
|
+
addToPluginsArrayOrCreate: addToPluginsArrayOrCreate,
|
|
48495
48589
|
addToVitePlugins: addToVitePlugins,
|
|
48496
48590
|
addToVitePluginsInFunction: addToVitePluginsInFunction,
|
|
48591
|
+
addToAstroIntegrations: addToAstroIntegrations,
|
|
48592
|
+
addToAstroIntegrationsInFunction: addToAstroIntegrationsInFunction,
|
|
48497
48593
|
addToRollupFunction: addToRollupFunction,
|
|
48498
48594
|
addToRollupArrayConfig: addToRollupArrayConfig,
|
|
48499
|
-
addToRolldownPlugins: addToRolldownPlugins,
|
|
48500
|
-
addToModernJSPlugins: addToModernJSPlugins,
|
|
48501
|
-
addToRSPressPlugins: addToRSPressPlugins,
|
|
48502
48595
|
wrapModuleExports: wrapModuleExports,
|
|
48503
48596
|
wrapExportDefault: wrapExportDefault,
|
|
48504
48597
|
skipAlreadyWrapped: skipAlreadyWrapped,
|
|
@@ -48509,7 +48602,7 @@ function normalizePathForOutput(filePath) {
|
|
|
48509
48602
|
}
|
|
48510
48603
|
function findConfigFiles(directory) {
|
|
48511
48604
|
const configFiles = [];
|
|
48512
|
-
for (const [bundlerName, config] of Object.entries(
|
|
48605
|
+
for (const [bundlerName, config] of Object.entries(src_BUNDLER_CONFIGS))for (const fileName of config.files){
|
|
48513
48606
|
const pattern = `${directory}/**/${fileName}`.replace(/\\/g, '/');
|
|
48514
48607
|
const matches = esm_glob.sync(pattern, {
|
|
48515
48608
|
ignore: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "with-zephyr",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.8",
|
|
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.0.0-canary.
|
|
41
|
+
"zephyr-rsbuild-plugin": "0.0.0-canary.8"
|
|
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"
|