vinext 0.0.30 → 0.0.31
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 +12 -6
- package/dist/build/prerender.d.ts +188 -0
- package/dist/build/prerender.js +675 -0
- package/dist/build/prerender.js.map +1 -0
- package/dist/build/report.d.ts +45 -46
- package/dist/build/report.js +247 -276
- package/dist/build/report.js.map +1 -1
- package/dist/build/run-prerender.d.ts +62 -0
- package/dist/build/run-prerender.js +183 -0
- package/dist/build/run-prerender.js.map +1 -0
- package/dist/build/server-manifest.d.ts +19 -0
- package/dist/build/server-manifest.js +29 -0
- package/dist/build/server-manifest.js.map +1 -0
- package/dist/build/static-export.d.ts +51 -66
- package/dist/build/static-export.js +51 -545
- package/dist/build/static-export.js.map +1 -1
- package/dist/check.d.ts +26 -24
- package/dist/check.js +591 -571
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +1 -15
- package/dist/cli.js +430 -491
- package/dist/cli.js.map +1 -1
- package/dist/client/entry.d.ts +1 -2
- package/dist/client/entry.js +49 -62
- package/dist/client/entry.js.map +1 -1
- package/dist/client/validate-module-path.d.ts +4 -1
- package/dist/client/validate-module-path.js +23 -28
- package/dist/client/validate-module-path.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +15 -20
- package/dist/client/vinext-next-data.js +0 -1
- package/dist/cloudflare/index.d.ts +3 -8
- package/dist/cloudflare/index.js +3 -8
- package/dist/cloudflare/kv-cache-handler.d.ts +95 -105
- package/dist/cloudflare/kv-cache-handler.js +354 -380
- package/dist/cloudflare/kv-cache-handler.js.map +1 -1
- package/dist/cloudflare/tpr.d.ts +36 -34
- package/dist/cloudflare/tpr.js +460 -603
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.d.ts +31 -40
- package/dist/config/config-matchers.js +727 -936
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/dotenv.d.ts +18 -11
- package/dist/config/dotenv.js +79 -84
- package/dist/config/dotenv.js.map +1 -1
- package/dist/config/next-config.d.ts +156 -146
- package/dist/config/next-config.js +374 -464
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.d.ts +87 -96
- package/dist/deploy.js +490 -628
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-browser-entry.d.ts +4 -1
- package/dist/entries/app-browser-entry.js +12 -8
- package/dist/entries/app-browser-entry.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +33 -20
- package/dist/entries/app-rsc-entry.js +442 -211
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/app-ssr-entry.d.ts +9 -1
- package/dist/entries/app-ssr-entry.js +61 -28
- package/dist/entries/app-ssr-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.d.ts +6 -2
- package/dist/entries/pages-client-entry.js +30 -33
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-entry-helpers.d.ts +5 -1
- package/dist/entries/pages-entry-helpers.js +17 -14
- package/dist/entries/pages-entry-helpers.js.map +1 -1
- package/dist/entries/pages-server-entry.d.ts +6 -2
- package/dist/entries/pages-server-entry.js +84 -113
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.d.ts +82 -62
- package/dist/index.js +2172 -3133
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +40 -37
- package/dist/init.js +201 -258
- package/dist/init.js.map +1 -1
- package/dist/plugins/async-hooks-stub.d.ts +7 -3
- package/dist/plugins/async-hooks-stub.js +39 -42
- package/dist/plugins/async-hooks-stub.js.map +1 -1
- package/dist/plugins/client-reference-dedup.d.ts +7 -3
- package/dist/plugins/client-reference-dedup.js +63 -88
- package/dist/plugins/client-reference-dedup.js.map +1 -1
- package/dist/routing/app-router.d.ts +100 -96
- package/dist/routing/app-router.js +560 -670
- package/dist/routing/app-router.js.map +1 -1
- package/dist/routing/file-matcher.d.ts +18 -15
- package/dist/routing/file-matcher.js +65 -65
- package/dist/routing/file-matcher.js.map +1 -1
- package/dist/routing/pages-router.d.ts +23 -24
- package/dist/routing/pages-router.js +147 -172
- package/dist/routing/pages-router.js.map +1 -1
- package/dist/routing/route-trie.d.ts +23 -20
- package/dist/routing/route-trie.js +131 -151
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/route-validation.d.ts +5 -2
- package/dist/routing/route-validation.js +98 -130
- package/dist/routing/route-validation.js.map +1 -1
- package/dist/routing/utils.d.ts +10 -7
- package/dist/routing/utils.js +75 -111
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.d.ts +8 -13
- package/dist/server/api-handler.js +161 -193
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-router-entry.d.ts +6 -16
- package/dist/server/app-router-entry.js +26 -54
- package/dist/server/app-router-entry.js.map +1 -1
- package/dist/server/dev-module-runner.d.ts +11 -64
- package/dist/server/dev-module-runner.js +89 -101
- package/dist/server/dev-module-runner.js.map +1 -1
- package/dist/server/dev-origin-check.d.ts +12 -10
- package/dist/server/dev-origin-check.js +98 -108
- package/dist/server/dev-origin-check.js.map +1 -1
- package/dist/server/dev-server.d.ts +17 -14
- package/dist/server/dev-server.js +542 -869
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/html.d.ts +4 -1
- package/dist/server/html.js +25 -26
- package/dist/server/html.js.map +1 -1
- package/dist/server/image-optimization.d.ts +31 -28
- package/dist/server/image-optimization.js +181 -210
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/instrumentation.d.ts +25 -22
- package/dist/server/instrumentation.js +110 -122
- package/dist/server/instrumentation.js.map +1 -1
- package/dist/server/isr-cache.d.ts +16 -26
- package/dist/server/isr-cache.js +106 -128
- package/dist/server/isr-cache.js.map +1 -1
- package/dist/server/metadata-routes.d.ts +85 -88
- package/dist/server/metadata-routes.js +270 -317
- package/dist/server/metadata-routes.js.map +1 -1
- package/dist/server/middleware-codegen.d.ts +7 -4
- package/dist/server/middleware-codegen.js +61 -61
- package/dist/server/middleware-codegen.js.map +1 -1
- package/dist/server/middleware-request-headers.d.ts +8 -6
- package/dist/server/middleware-request-headers.js +47 -65
- package/dist/server/middleware-request-headers.js.map +1 -1
- package/dist/server/middleware.d.ts +31 -47
- package/dist/server/middleware.js +273 -404
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/normalize-path.d.ts +4 -1
- package/dist/server/normalize-path.js +33 -47
- package/dist/server/normalize-path.js.map +1 -1
- package/dist/server/pages-i18n.d.ts +38 -30
- package/dist/server/pages-i18n.js +112 -139
- package/dist/server/pages-i18n.js.map +1 -1
- package/dist/server/prod-server.d.ts +19 -31
- package/dist/server/prod-server.js +714 -945
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/request-log.d.ts +18 -12
- package/dist/server/request-log.js +45 -52
- package/dist/server/request-log.js.map +1 -1
- package/dist/server/request-pipeline.d.ts +9 -17
- package/dist/server/request-pipeline.js +133 -184
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/worker-utils.d.ts +4 -1
- package/dist/server/worker-utils.js +31 -37
- package/dist/server/worker-utils.js.map +1 -1
- package/dist/shims/amp.d.ts +5 -2
- package/dist/shims/amp.js +19 -15
- package/dist/shims/amp.js.map +1 -1
- package/dist/shims/app.d.ts +8 -10
- package/dist/shims/app.js +0 -1
- package/dist/shims/cache-runtime.d.ts +20 -45
- package/dist/shims/cache-runtime.js +271 -422
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/cache.d.ts +130 -121
- package/dist/shims/cache.js +339 -427
- package/dist/shims/cache.js.map +1 -1
- package/dist/shims/client-only.d.ts +1 -18
- package/dist/shims/client-only.js +0 -17
- package/dist/shims/compat-router.d.ts +4 -1
- package/dist/shims/compat-router.js +23 -19
- package/dist/shims/compat-router.js.map +1 -1
- package/dist/shims/config.d.ts +7 -5
- package/dist/shims/config.js +16 -23
- package/dist/shims/config.js.map +1 -1
- package/dist/shims/constants.d.ts +119 -118
- package/dist/shims/constants.js +159 -164
- package/dist/shims/constants.js.map +1 -1
- package/dist/shims/document.d.ts +20 -16
- package/dist/shims/document.js +41 -22
- package/dist/shims/document.js.map +1 -1
- package/dist/shims/dynamic.d.ts +13 -22
- package/dist/shims/dynamic.js +122 -136
- package/dist/shims/dynamic.js.map +1 -1
- package/dist/shims/error-boundary.d.ts +22 -15
- package/dist/shims/error-boundary.js +81 -79
- package/dist/shims/error-boundary.js.map +1 -1
- package/dist/shims/error.d.ts +11 -12
- package/dist/shims/error.js +35 -39
- package/dist/shims/error.js.map +1 -1
- package/dist/shims/fetch-cache.d.ts +16 -14
- package/dist/shims/fetch-cache.js +437 -645
- package/dist/shims/fetch-cache.js.map +1 -1
- package/dist/shims/font-google-base.d.ts +28 -26
- package/dist/shims/font-google-base.js +238 -325
- package/dist/shims/font-google-base.js.map +1 -1
- package/dist/shims/font-google.d.ts +3 -3
- package/dist/shims/font-google.generated.d.ts +1928 -1924
- package/dist/shims/font-google.generated.js +1928 -2133
- package/dist/shims/font-google.generated.js.map +1 -1
- package/dist/shims/font-google.js +3 -3
- package/dist/shims/font-local.d.ts +28 -26
- package/dist/shims/font-local.js +204 -260
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/form.d.ts +13 -27
- package/dist/shims/form.js +128 -180
- package/dist/shims/form.js.map +1 -1
- package/dist/shims/head-state.d.ts +8 -13
- package/dist/shims/head-state.js +25 -42
- package/dist/shims/head-state.js.map +1 -1
- package/dist/shims/head.d.ts +16 -20
- package/dist/shims/head.js +172 -250
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +84 -78
- package/dist/shims/headers.js +447 -575
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/i18n-context.d.ts +16 -20
- package/dist/shims/i18n-context.js +35 -48
- package/dist/shims/i18n-context.js.map +1 -1
- package/dist/shims/i18n-state.d.ts +8 -14
- package/dist/shims/i18n-state.js +34 -42
- package/dist/shims/i18n-state.js.map +1 -1
- package/dist/shims/image-config.d.ts +11 -8
- package/dist/shims/image-config.js +50 -83
- package/dist/shims/image-config.js.map +1 -1
- package/dist/shims/image.d.ts +37 -46
- package/dist/shims/image.js +283 -308
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/api-utils.d.ts +7 -4
- package/dist/shims/internal/api-utils.js +0 -6
- package/dist/shims/internal/app-router-context.d.ts +22 -17
- package/dist/shims/internal/app-router-context.js +17 -13
- package/dist/shims/internal/app-router-context.js.map +1 -1
- package/dist/shims/internal/cookies.d.ts +2 -9
- package/dist/shims/internal/cookies.js +2 -9
- package/dist/shims/internal/parse-cookie-header.d.ts +4 -1
- package/dist/shims/internal/parse-cookie-header.js +29 -29
- package/dist/shims/internal/parse-cookie-header.js.map +1 -1
- package/dist/shims/internal/router-context.d.ts +6 -1
- package/dist/shims/internal/router-context.js +11 -7
- package/dist/shims/internal/router-context.js.map +1 -1
- package/dist/shims/internal/utils.d.ts +40 -37
- package/dist/shims/internal/utils.js +24 -30
- package/dist/shims/internal/utils.js.map +1 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts +6 -10
- package/dist/shims/internal/work-unit-async-storage.js +14 -11
- package/dist/shims/internal/work-unit-async-storage.js.map +1 -1
- package/dist/shims/layout-segment-context.d.ts +11 -14
- package/dist/shims/layout-segment-context.js +24 -23
- package/dist/shims/layout-segment-context.js.map +1 -1
- package/dist/shims/legacy-image.d.ts +39 -46
- package/dist/shims/legacy-image.js +47 -42
- package/dist/shims/legacy-image.js.map +1 -1
- package/dist/shims/link.d.ts +32 -36
- package/dist/shims/link.js +255 -391
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +210 -202
- package/dist/shims/metadata.js +545 -546
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation-state.d.ts +10 -18
- package/dist/shims/navigation-state.js +66 -74
- package/dist/shims/navigation-state.js.map +1 -1
- package/dist/shims/navigation.d.ts +59 -63
- package/dist/shims/navigation.js +505 -704
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/og.d.ts +2 -20
- package/dist/shims/og.js +2 -19
- package/dist/shims/readonly-url-search-params.d.ts +8 -5
- package/dist/shims/readonly-url-search-params.js +26 -22
- package/dist/shims/readonly-url-search-params.js.map +1 -1
- package/dist/shims/request-context.d.ts +8 -5
- package/dist/shims/request-context.js +50 -60
- package/dist/shims/request-context.js.map +1 -1
- package/dist/shims/request-state-types.d.ts +11 -11
- package/dist/shims/request-state-types.js +0 -1
- package/dist/shims/router-state.d.ts +13 -10
- package/dist/shims/router-state.js +34 -43
- package/dist/shims/router-state.js.map +1 -1
- package/dist/shims/router.d.ts +81 -85
- package/dist/shims/router.js +506 -628
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.d.ts +39 -48
- package/dist/shims/script.js +107 -160
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server-only.d.ts +1 -19
- package/dist/shims/server-only.js +0 -18
- package/dist/shims/server.d.ts +175 -164
- package/dist/shims/server.js +462 -478
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/unified-request-context.d.ts +20 -20
- package/dist/shims/unified-request-context.js +81 -99
- package/dist/shims/unified-request-context.js.map +1 -1
- package/dist/shims/url-safety.d.ts +4 -1
- package/dist/shims/url-safety.js +15 -11
- package/dist/shims/url-safety.js.map +1 -1
- package/dist/shims/url-utils.d.ts +8 -5
- package/dist/shims/url-utils.js +62 -93
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/shims/web-vitals.d.ts +10 -8
- package/dist/shims/web-vitals.js +9 -15
- package/dist/shims/web-vitals.js.map +1 -1
- package/dist/utils/base-path.d.ts +5 -2
- package/dist/utils/base-path.js +21 -19
- package/dist/utils/base-path.js.map +1 -1
- package/dist/utils/domain-locale.d.ts +17 -9
- package/dist/utils/domain-locale.js +36 -56
- package/dist/utils/domain-locale.js.map +1 -1
- package/dist/utils/hash.d.ts +4 -1
- package/dist/utils/hash.js +19 -17
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/manifest-paths.d.ts +6 -3
- package/dist/utils/manifest-paths.js +15 -16
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/project.d.ts +13 -11
- package/dist/utils/project.js +169 -216
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/query.d.ts +8 -6
- package/dist/utils/query.js +57 -67
- package/dist/utils/query.js.map +1 -1
- package/package.json +10 -9
- package/dist/build/report.d.ts.map +0 -1
- package/dist/build/static-export.d.ts.map +0 -1
- package/dist/check.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/entry.d.ts.map +0 -1
- package/dist/client/validate-module-path.d.ts.map +0 -1
- package/dist/client/vinext-next-data.d.ts.map +0 -1
- package/dist/client/vinext-next-data.js.map +0 -1
- package/dist/cloudflare/index.d.ts.map +0 -1
- package/dist/cloudflare/index.js.map +0 -1
- package/dist/cloudflare/kv-cache-handler.d.ts.map +0 -1
- package/dist/cloudflare/tpr.d.ts.map +0 -1
- package/dist/config/config-matchers.d.ts.map +0 -1
- package/dist/config/dotenv.d.ts.map +0 -1
- package/dist/config/next-config.d.ts.map +0 -1
- package/dist/deploy.d.ts.map +0 -1
- package/dist/entries/app-browser-entry.d.ts.map +0 -1
- package/dist/entries/app-rsc-entry.d.ts.map +0 -1
- package/dist/entries/app-ssr-entry.d.ts.map +0 -1
- package/dist/entries/pages-client-entry.d.ts.map +0 -1
- package/dist/entries/pages-entry-helpers.d.ts.map +0 -1
- package/dist/entries/pages-server-entry.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init.d.ts.map +0 -1
- package/dist/plugins/async-hooks-stub.d.ts.map +0 -1
- package/dist/plugins/client-reference-dedup.d.ts.map +0 -1
- package/dist/routing/app-router.d.ts.map +0 -1
- package/dist/routing/file-matcher.d.ts.map +0 -1
- package/dist/routing/pages-router.d.ts.map +0 -1
- package/dist/routing/route-trie.d.ts.map +0 -1
- package/dist/routing/route-validation.d.ts.map +0 -1
- package/dist/routing/utils.d.ts.map +0 -1
- package/dist/server/api-handler.d.ts.map +0 -1
- package/dist/server/app-router-entry.d.ts.map +0 -1
- package/dist/server/dev-module-runner.d.ts.map +0 -1
- package/dist/server/dev-origin-check.d.ts.map +0 -1
- package/dist/server/dev-server.d.ts.map +0 -1
- package/dist/server/html.d.ts.map +0 -1
- package/dist/server/image-optimization.d.ts.map +0 -1
- package/dist/server/instrumentation.d.ts.map +0 -1
- package/dist/server/isr-cache.d.ts.map +0 -1
- package/dist/server/metadata-routes.d.ts.map +0 -1
- package/dist/server/middleware-codegen.d.ts.map +0 -1
- package/dist/server/middleware-request-headers.d.ts.map +0 -1
- package/dist/server/middleware.d.ts.map +0 -1
- package/dist/server/normalize-path.d.ts.map +0 -1
- package/dist/server/pages-i18n.d.ts.map +0 -1
- package/dist/server/prod-server.d.ts.map +0 -1
- package/dist/server/request-log.d.ts.map +0 -1
- package/dist/server/request-pipeline.d.ts.map +0 -1
- package/dist/server/worker-utils.d.ts.map +0 -1
- package/dist/shims/amp.d.ts.map +0 -1
- package/dist/shims/app.d.ts.map +0 -1
- package/dist/shims/app.js.map +0 -1
- package/dist/shims/cache-runtime.d.ts.map +0 -1
- package/dist/shims/cache.d.ts.map +0 -1
- package/dist/shims/client-only.d.ts.map +0 -1
- package/dist/shims/client-only.js.map +0 -1
- package/dist/shims/compat-router.d.ts.map +0 -1
- package/dist/shims/config.d.ts.map +0 -1
- package/dist/shims/constants.d.ts.map +0 -1
- package/dist/shims/document.d.ts.map +0 -1
- package/dist/shims/dynamic.d.ts.map +0 -1
- package/dist/shims/error-boundary.d.ts.map +0 -1
- package/dist/shims/error.d.ts.map +0 -1
- package/dist/shims/fetch-cache.d.ts.map +0 -1
- package/dist/shims/font-google-base.d.ts.map +0 -1
- package/dist/shims/font-google.d.ts.map +0 -1
- package/dist/shims/font-google.generated.d.ts.map +0 -1
- package/dist/shims/font-google.js.map +0 -1
- package/dist/shims/font-local.d.ts.map +0 -1
- package/dist/shims/form.d.ts.map +0 -1
- package/dist/shims/head-state.d.ts.map +0 -1
- package/dist/shims/head.d.ts.map +0 -1
- package/dist/shims/headers.d.ts.map +0 -1
- package/dist/shims/i18n-context.d.ts.map +0 -1
- package/dist/shims/i18n-state.d.ts.map +0 -1
- package/dist/shims/image-config.d.ts.map +0 -1
- package/dist/shims/image.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.d.ts.map +0 -1
- package/dist/shims/internal/api-utils.js.map +0 -1
- package/dist/shims/internal/app-router-context.d.ts.map +0 -1
- package/dist/shims/internal/cookies.d.ts.map +0 -1
- package/dist/shims/internal/cookies.js.map +0 -1
- package/dist/shims/internal/parse-cookie-header.d.ts.map +0 -1
- package/dist/shims/internal/router-context.d.ts.map +0 -1
- package/dist/shims/internal/utils.d.ts.map +0 -1
- package/dist/shims/internal/work-unit-async-storage.d.ts.map +0 -1
- package/dist/shims/layout-segment-context.d.ts.map +0 -1
- package/dist/shims/legacy-image.d.ts.map +0 -1
- package/dist/shims/link.d.ts.map +0 -1
- package/dist/shims/metadata.d.ts.map +0 -1
- package/dist/shims/navigation-state.d.ts.map +0 -1
- package/dist/shims/navigation.d.ts.map +0 -1
- package/dist/shims/og.d.ts.map +0 -1
- package/dist/shims/og.js.map +0 -1
- package/dist/shims/readonly-url-search-params.d.ts.map +0 -1
- package/dist/shims/request-context.d.ts.map +0 -1
- package/dist/shims/request-state-types.d.ts.map +0 -1
- package/dist/shims/request-state-types.js.map +0 -1
- package/dist/shims/router-state.d.ts.map +0 -1
- package/dist/shims/router.d.ts.map +0 -1
- package/dist/shims/script.d.ts.map +0 -1
- package/dist/shims/server-only.d.ts.map +0 -1
- package/dist/shims/server-only.js.map +0 -1
- package/dist/shims/server.d.ts.map +0 -1
- package/dist/shims/unified-request-context.d.ts.map +0 -1
- package/dist/shims/url-safety.d.ts.map +0 -1
- package/dist/shims/url-utils.d.ts.map +0 -1
- package/dist/shims/web-vitals.d.ts.map +0 -1
- package/dist/utils/base-path.d.ts.map +0 -1
- package/dist/utils/domain-locale.d.ts.map +0 -1
- package/dist/utils/hash.d.ts.map +0 -1
- package/dist/utils/manifest-paths.d.ts.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/query.d.ts.map +0 -1
package/dist/deploy.js
CHANGED
|
@@ -1,345 +1,268 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Takes any Next.js app and deploys it to Cloudflare Workers:
|
|
5
|
-
*
|
|
6
|
-
* 1. Detects App Router vs Pages Router
|
|
7
|
-
* 2. Auto-generates missing config files (wrangler.jsonc, worker/index.ts, vite.config.ts)
|
|
8
|
-
* 3. Ensures dependencies are installed (@cloudflare/vite-plugin, wrangler, @vitejs/plugin-rsc)
|
|
9
|
-
* 4. Runs the Vite build
|
|
10
|
-
* 5. Deploys to Cloudflare Workers via wrangler
|
|
11
|
-
*
|
|
12
|
-
* Design: Everything is auto-generated into a `.vinext/` directory (not the
|
|
13
|
-
* project root) to avoid cluttering the user's project. If the user already
|
|
14
|
-
* has these files, we use theirs.
|
|
15
|
-
*/
|
|
16
|
-
import fs from "node:fs";
|
|
17
|
-
import path from "node:path";
|
|
18
|
-
import { createRequire } from "node:module";
|
|
19
|
-
import { execFileSync } from "node:child_process";
|
|
20
|
-
import { parseArgs as nodeParseArgs } from "node:util";
|
|
21
|
-
import { createBuilder, build } from "vite";
|
|
22
|
-
import { ensureESModule as _ensureESModule, renameCJSConfigs as _renameCJSConfigs, detectPackageManager as _detectPackageManager, findInNodeModules as _findInNodeModules, } from "./utils/project.js";
|
|
1
|
+
import { detectPackageManager as detectPackageManager$1, ensureESModule as ensureESModule$1, findInNodeModules, renameCJSConfigs as renameCJSConfigs$1 } from "./utils/project.js";
|
|
2
|
+
import { loadNextConfig, resolveNextConfig } from "./config/next-config.js";
|
|
23
3
|
import { getReactUpgradeDeps } from "./init.js";
|
|
24
4
|
import { runTPR } from "./cloudflare/tpr.js";
|
|
5
|
+
import { runPrerender } from "./build/run-prerender.js";
|
|
25
6
|
import { loadDotenv } from "./config/dotenv.js";
|
|
26
|
-
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
import { parseArgs } from "node:util";
|
|
13
|
+
//#region src/deploy.ts
|
|
14
|
+
/**
|
|
15
|
+
* vinext deploy — one-command Cloudflare Workers deployment.
|
|
16
|
+
*
|
|
17
|
+
* Takes any Next.js app and deploys it to Cloudflare Workers:
|
|
18
|
+
*
|
|
19
|
+
* 1. Detects App Router vs Pages Router
|
|
20
|
+
* 2. Auto-generates missing config files (wrangler.jsonc, worker/index.ts, vite.config.ts)
|
|
21
|
+
* 3. Ensures dependencies are installed (@cloudflare/vite-plugin, wrangler, @vitejs/plugin-react, App Router deps)
|
|
22
|
+
* 4. Runs the Vite build
|
|
23
|
+
* 5. Deploys to Cloudflare Workers via wrangler
|
|
24
|
+
*
|
|
25
|
+
* Design: Everything is auto-generated into a `.vinext/` directory (not the
|
|
26
|
+
* project root) to avoid cluttering the user's project. If the user already
|
|
27
|
+
* has these files, we use theirs.
|
|
28
|
+
*/
|
|
27
29
|
/** Deploy command flag definitions for util.parseArgs. */
|
|
28
30
|
const deployArgOptions = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
help: {
|
|
32
|
+
type: "boolean",
|
|
33
|
+
short: "h",
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
preview: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
env: { type: "string" },
|
|
41
|
+
name: { type: "string" },
|
|
42
|
+
"skip-build": {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
"dry-run": {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
"prerender-all": {
|
|
51
|
+
type: "boolean",
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
"experimental-tpr": {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
default: false
|
|
57
|
+
},
|
|
58
|
+
"tpr-coverage": { type: "string" },
|
|
59
|
+
"tpr-limit": { type: "string" },
|
|
60
|
+
"tpr-window": { type: "string" }
|
|
39
61
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
function parseDeployArgs(args) {
|
|
63
|
+
const { values } = parseArgs({
|
|
64
|
+
args,
|
|
65
|
+
options: deployArgOptions,
|
|
66
|
+
strict: true
|
|
67
|
+
});
|
|
68
|
+
function parseIntArg(name, raw) {
|
|
69
|
+
if (!raw) return void 0;
|
|
70
|
+
const n = parseInt(raw, 10);
|
|
71
|
+
if (isNaN(n)) {
|
|
72
|
+
console.error(` --${name} must be a number (got: ${raw})`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
help: values.help,
|
|
79
|
+
preview: values.preview,
|
|
80
|
+
env: values.env?.trim() || void 0,
|
|
81
|
+
name: values.name?.trim() || void 0,
|
|
82
|
+
skipBuild: values["skip-build"],
|
|
83
|
+
dryRun: values["dry-run"],
|
|
84
|
+
prerenderAll: values["prerender-all"],
|
|
85
|
+
experimentalTPR: values["experimental-tpr"],
|
|
86
|
+
tprCoverage: parseIntArg("tpr-coverage", values["tpr-coverage"]),
|
|
87
|
+
tprLimit: parseIntArg("tpr-limit", values["tpr-limit"]),
|
|
88
|
+
tprWindow: parseIntArg("tpr-window", values["tpr-window"])
|
|
89
|
+
};
|
|
54
90
|
}
|
|
55
|
-
// ─── Detection ───────────────────────────────────────────────────────────────
|
|
56
91
|
/** Check whether a wrangler config file exists in the given directory. */
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
fs.existsSync(path.join(root, "wrangler.json")) ||
|
|
60
|
-
fs.existsSync(path.join(root, "wrangler.toml")));
|
|
92
|
+
function hasWranglerConfig(root) {
|
|
93
|
+
return fs.existsSync(path.join(root, "wrangler.jsonc")) || fs.existsSync(path.join(root, "wrangler.json")) || fs.existsSync(path.join(root, "wrangler.toml"));
|
|
61
94
|
}
|
|
62
95
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const configRef = options.configFile ? options.configFile : "your Vite config";
|
|
72
|
-
return (`[vinext] Missing @cloudflare/vite-plugin in ${configRef}.\n\n` +
|
|
73
|
-
` Cloudflare Workers builds require the cloudflare() plugin.\n` +
|
|
74
|
-
` Add it to ${configRef}:\n\n` +
|
|
75
|
-
` import { cloudflare } from "@cloudflare/vite-plugin";\n\n` +
|
|
76
|
-
` export default defineConfig({\n` +
|
|
77
|
-
` plugins: [\n` +
|
|
78
|
-
` vinext(),\n` +
|
|
79
|
-
` cloudflare(${cfArg}),\n` +
|
|
80
|
-
` ],\n` +
|
|
81
|
-
` });\n\n` +
|
|
82
|
-
` Or delete ${configRef} and re-run \`vinext deploy\` to auto-generate it.`);
|
|
96
|
+
* Build the error message thrown when cloudflare() is missing from the Vite config.
|
|
97
|
+
* Shared between the build-time guard (index.ts configResolved) and the
|
|
98
|
+
* deploy-time guard (deploy.ts deploy()).
|
|
99
|
+
*/
|
|
100
|
+
function formatMissingCloudflarePluginError(options) {
|
|
101
|
+
const cfArg = options.isAppRouter ? "{\n viteEnvironment: { name: \"rsc\", childEnvironments: [\"ssr\"] },\n }" : "";
|
|
102
|
+
const configRef = options.configFile ? options.configFile : "your Vite config";
|
|
103
|
+
return `[vinext] Missing @cloudflare/vite-plugin in ${configRef}.\n\n Cloudflare Workers builds require the cloudflare() plugin.\n Add it to ${configRef}:\n\n import { cloudflare } from "@cloudflare/vite-plugin";\n\n export default defineConfig({\n plugins: [\n vinext(),\n cloudflare(${cfArg}),\n ],\n });\n\n Or delete ${configRef} and re-run \`vinext deploy\` to auto-generate it.`;
|
|
83
104
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
129
|
-
hasTypeModule = pkg.type === "module";
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
// ignore
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// Detect MDX usage
|
|
136
|
-
const hasMDX = detectMDX(root, isAppRouter, hasPages);
|
|
137
|
-
// Detect CodeHike dependency
|
|
138
|
-
let hasCodeHike = false;
|
|
139
|
-
if (fs.existsSync(pkgPath)) {
|
|
140
|
-
try {
|
|
141
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
142
|
-
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
143
|
-
hasCodeHike = "codehike" in allDeps;
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
// ignore
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
// Detect native Node modules that need stubbing for Workers
|
|
150
|
-
const nativeModulesToStub = detectNativeModules(root);
|
|
151
|
-
return {
|
|
152
|
-
root,
|
|
153
|
-
isAppRouter,
|
|
154
|
-
isPagesRouter,
|
|
155
|
-
hasViteConfig,
|
|
156
|
-
hasWranglerConfig: wranglerConfigExists,
|
|
157
|
-
hasWorkerEntry,
|
|
158
|
-
hasCloudflarePlugin,
|
|
159
|
-
hasRscPlugin,
|
|
160
|
-
hasWrangler,
|
|
161
|
-
projectName,
|
|
162
|
-
hasISR,
|
|
163
|
-
hasTypeModule,
|
|
164
|
-
hasMDX,
|
|
165
|
-
hasCodeHike,
|
|
166
|
-
nativeModulesToStub,
|
|
167
|
-
};
|
|
105
|
+
function detectProject(root) {
|
|
106
|
+
const hasApp = fs.existsSync(path.join(root, "app")) || fs.existsSync(path.join(root, "src", "app"));
|
|
107
|
+
const hasPages = fs.existsSync(path.join(root, "pages")) || fs.existsSync(path.join(root, "src", "pages"));
|
|
108
|
+
const isAppRouter = hasApp;
|
|
109
|
+
const isPagesRouter = !hasApp && hasPages;
|
|
110
|
+
const hasViteConfig = fs.existsSync(path.join(root, "vite.config.ts")) || fs.existsSync(path.join(root, "vite.config.js")) || fs.existsSync(path.join(root, "vite.config.mjs"));
|
|
111
|
+
const wranglerConfigExists = hasWranglerConfig(root);
|
|
112
|
+
const hasWorkerEntry = fs.existsSync(path.join(root, "worker", "index.ts")) || fs.existsSync(path.join(root, "worker", "index.js"));
|
|
113
|
+
const hasCloudflarePlugin = findInNodeModules(root, "@cloudflare/vite-plugin") !== null;
|
|
114
|
+
const hasRscPlugin = findInNodeModules(root, "@vitejs/plugin-rsc") !== null;
|
|
115
|
+
const hasWrangler = findInNodeModules(root, ".bin/wrangler") !== null;
|
|
116
|
+
const pkgPath = path.join(root, "package.json");
|
|
117
|
+
let pkg = null;
|
|
118
|
+
if (fs.existsSync(pkgPath)) try {
|
|
119
|
+
pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
120
|
+
} catch {}
|
|
121
|
+
let projectName = path.basename(root);
|
|
122
|
+
if (pkg?.name && typeof pkg.name === "string") projectName = pkg.name.replace(/^@[^/]+\//, "").toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
123
|
+
const hasISR = detectISR(root, isAppRouter);
|
|
124
|
+
const hasTypeModule = pkg?.type === "module";
|
|
125
|
+
const hasMDX = detectMDX(root, isAppRouter, hasPages);
|
|
126
|
+
const hasCodeHike = "codehike" in {
|
|
127
|
+
...pkg?.dependencies,
|
|
128
|
+
...pkg?.devDependencies
|
|
129
|
+
};
|
|
130
|
+
const nativeModulesToStub = detectNativeModules(root);
|
|
131
|
+
return {
|
|
132
|
+
root,
|
|
133
|
+
isAppRouter,
|
|
134
|
+
isPagesRouter,
|
|
135
|
+
hasViteConfig,
|
|
136
|
+
hasWranglerConfig: wranglerConfigExists,
|
|
137
|
+
hasWorkerEntry,
|
|
138
|
+
hasCloudflarePlugin,
|
|
139
|
+
hasRscPlugin,
|
|
140
|
+
hasWrangler,
|
|
141
|
+
projectName,
|
|
142
|
+
hasISR,
|
|
143
|
+
hasTypeModule,
|
|
144
|
+
hasMDX,
|
|
145
|
+
hasCodeHike,
|
|
146
|
+
nativeModulesToStub
|
|
147
|
+
};
|
|
168
148
|
}
|
|
169
149
|
function detectISR(root, isAppRouter) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return false;
|
|
180
|
-
// Quick check: search .ts/.tsx files in app/ for `export const revalidate`
|
|
181
|
-
return scanDirForPattern(appDir, /export\s+const\s+revalidate\s*=/);
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
150
|
+
if (!isAppRouter) return false;
|
|
151
|
+
try {
|
|
152
|
+
let appDir = path.join(root, "app");
|
|
153
|
+
if (!fs.existsSync(appDir)) appDir = path.join(root, "src", "app");
|
|
154
|
+
if (!fs.existsSync(appDir)) return false;
|
|
155
|
+
return scanDirForPattern(appDir, /export\s+const\s+revalidate\s*=/);
|
|
156
|
+
} catch {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
186
159
|
}
|
|
187
160
|
function scanDirForPattern(dir, pattern) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
catch {
|
|
202
|
-
// skip unreadable files
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return false;
|
|
161
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
162
|
+
for (const entry of entries) {
|
|
163
|
+
const fullPath = path.join(dir, entry.name);
|
|
164
|
+
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
165
|
+
if (scanDirForPattern(fullPath, pattern)) return true;
|
|
166
|
+
} else if (entry.isFile() && /\.(ts|tsx|js|jsx)$/.test(entry.name)) try {
|
|
167
|
+
const content = fs.readFileSync(fullPath, "utf-8");
|
|
168
|
+
if (pattern.test(content)) return true;
|
|
169
|
+
} catch {}
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
207
172
|
}
|
|
208
173
|
/**
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
174
|
+
* Detect .mdx files in the project's app/ or pages/ directory,
|
|
175
|
+
* or `pageExtensions` including "mdx" in next.config.
|
|
176
|
+
*/
|
|
212
177
|
function detectMDX(root, isAppRouter, hasPages) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (hasPages) {
|
|
237
|
-
const pagesDir = fs.existsSync(path.join(root, "pages"))
|
|
238
|
-
? path.join(root, "pages")
|
|
239
|
-
: path.join(root, "src", "pages");
|
|
240
|
-
dirs.push(pagesDir);
|
|
241
|
-
}
|
|
242
|
-
for (const dir of dirs) {
|
|
243
|
-
if (fs.existsSync(dir) && scanDirForExtension(dir, ".mdx"))
|
|
244
|
-
return true;
|
|
245
|
-
}
|
|
246
|
-
return false;
|
|
178
|
+
for (const f of [
|
|
179
|
+
"next.config.ts",
|
|
180
|
+
"next.config.mjs",
|
|
181
|
+
"next.config.js",
|
|
182
|
+
"next.config.cjs"
|
|
183
|
+
]) {
|
|
184
|
+
const p = path.join(root, f);
|
|
185
|
+
if (fs.existsSync(p)) try {
|
|
186
|
+
const content = fs.readFileSync(p, "utf-8");
|
|
187
|
+
if (/pageExtensions.*mdx/i.test(content) || /@next\/mdx/.test(content)) return true;
|
|
188
|
+
} catch {}
|
|
189
|
+
}
|
|
190
|
+
const dirs = [];
|
|
191
|
+
if (isAppRouter) {
|
|
192
|
+
const appDir = fs.existsSync(path.join(root, "app")) ? path.join(root, "app") : path.join(root, "src", "app");
|
|
193
|
+
dirs.push(appDir);
|
|
194
|
+
}
|
|
195
|
+
if (hasPages) {
|
|
196
|
+
const pagesDir = fs.existsSync(path.join(root, "pages")) ? path.join(root, "pages") : path.join(root, "src", "pages");
|
|
197
|
+
dirs.push(pagesDir);
|
|
198
|
+
}
|
|
199
|
+
for (const dir of dirs) if (fs.existsSync(dir) && scanDirForExtension(dir, ".mdx")) return true;
|
|
200
|
+
return false;
|
|
247
201
|
}
|
|
248
202
|
function scanDirForExtension(dir, ext) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return false;
|
|
203
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
204
|
+
for (const entry of entries) {
|
|
205
|
+
const fullPath = path.join(dir, entry.name);
|
|
206
|
+
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
207
|
+
if (scanDirForExtension(fullPath, ext)) return true;
|
|
208
|
+
} else if (entry.isFile() && entry.name.endsWith(ext)) return true;
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
261
211
|
}
|
|
262
212
|
/** Known native Node modules that can't run in Workers */
|
|
263
213
|
const NATIVE_MODULES_TO_STUB = [
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
214
|
+
"@resvg/resvg-js",
|
|
215
|
+
"satori",
|
|
216
|
+
"lightningcss",
|
|
217
|
+
"@napi-rs/canvas",
|
|
218
|
+
"sharp"
|
|
269
219
|
];
|
|
270
220
|
/**
|
|
271
|
-
|
|
272
|
-
|
|
221
|
+
* Detect native Node modules in dependencies that need stubbing for Workers.
|
|
222
|
+
*/
|
|
273
223
|
function detectNativeModules(root) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
224
|
+
const pkgPath = path.join(root, "package.json");
|
|
225
|
+
if (!fs.existsSync(pkgPath)) return [];
|
|
226
|
+
try {
|
|
227
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
228
|
+
const allDeps = {
|
|
229
|
+
...pkg.dependencies,
|
|
230
|
+
...pkg.devDependencies
|
|
231
|
+
};
|
|
232
|
+
return NATIVE_MODULES_TO_STUB.filter((mod) => mod in allDeps);
|
|
233
|
+
} catch {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
285
236
|
}
|
|
286
|
-
// ─── Project Preparation (pre-build transforms) ─────────────────────────────
|
|
287
|
-
//
|
|
288
|
-
// These are delegated to shared utilities in ./utils/project.ts so they can
|
|
289
|
-
// be reused by both `vinext deploy` and `vinext init`.
|
|
290
237
|
/** @see {@link _ensureESModule} */
|
|
291
|
-
|
|
238
|
+
const ensureESModule = ensureESModule$1;
|
|
292
239
|
/** @see {@link _renameCJSConfigs} */
|
|
293
|
-
|
|
294
|
-
// ─── File Generation ─────────────────────────────────────────────────────────
|
|
240
|
+
const renameCJSConfigs = renameCJSConfigs$1;
|
|
295
241
|
/** Generate wrangler.jsonc content */
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
};
|
|
317
|
-
if (info.hasISR) {
|
|
318
|
-
config.kv_namespaces = [
|
|
319
|
-
{
|
|
320
|
-
binding: "VINEXT_CACHE",
|
|
321
|
-
id: "<your-kv-namespace-id>",
|
|
322
|
-
},
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
return JSON.stringify(config, null, 2) + "\n";
|
|
242
|
+
function generateWranglerConfig(info) {
|
|
243
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
244
|
+
const config = {
|
|
245
|
+
$schema: "node_modules/wrangler/config-schema.json",
|
|
246
|
+
name: info.projectName,
|
|
247
|
+
compatibility_date: today,
|
|
248
|
+
compatibility_flags: ["nodejs_compat"],
|
|
249
|
+
main: "./worker/index.ts",
|
|
250
|
+
assets: {
|
|
251
|
+
directory: "dist/client",
|
|
252
|
+
not_found_handling: "none",
|
|
253
|
+
binding: "ASSETS"
|
|
254
|
+
},
|
|
255
|
+
images: { binding: "IMAGES" }
|
|
256
|
+
};
|
|
257
|
+
if (info.hasISR) config.kv_namespaces = [{
|
|
258
|
+
binding: "VINEXT_CACHE",
|
|
259
|
+
id: "<your-kv-namespace-id>"
|
|
260
|
+
}];
|
|
261
|
+
return JSON.stringify(config, null, 2) + "\n";
|
|
326
262
|
}
|
|
327
263
|
/** Generate worker/index.ts for App Router */
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
? `import { KVCacheHandler } from "vinext/cloudflare";
|
|
331
|
-
import { setCacheHandler } from "vinext/shims/cache";
|
|
332
|
-
`
|
|
333
|
-
: "";
|
|
334
|
-
const isrEnvField = hasISR ? `\n VINEXT_CACHE: KVNamespace;` : "";
|
|
335
|
-
const isrSetup = hasISR
|
|
336
|
-
? ` // Wire up KV-backed ISR cache. The vinext RSC entry automatically
|
|
337
|
-
// registers ctx in ALS so background KV puts use waitUntil — without
|
|
338
|
-
// this every request would return MISS.
|
|
339
|
-
setCacheHandler(new KVCacheHandler(env.VINEXT_CACHE));
|
|
340
|
-
`
|
|
341
|
-
: "";
|
|
342
|
-
return `/**
|
|
264
|
+
function generateAppRouterWorkerEntry(hasISR = false) {
|
|
265
|
+
return `/**
|
|
343
266
|
* Cloudflare Worker entry point — auto-generated by vinext deploy.
|
|
344
267
|
* Edit freely or delete to regenerate on next deploy.
|
|
345
268
|
*
|
|
@@ -349,9 +272,11 @@ import { setCacheHandler } from "vinext/shims/cache";
|
|
|
349
272
|
import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "vinext/server/image-optimization";
|
|
350
273
|
import type { ImageConfig } from "vinext/server/image-optimization";
|
|
351
274
|
import handler from "vinext/server/app-router-entry";
|
|
352
|
-
${
|
|
275
|
+
${hasISR ? `import { KVCacheHandler } from "vinext/cloudflare";
|
|
276
|
+
import { setCacheHandler } from "vinext/shims/cache";
|
|
277
|
+
` : ""}
|
|
353
278
|
interface Env {
|
|
354
|
-
ASSETS: Fetcher;${
|
|
279
|
+
ASSETS: Fetcher;${hasISR ? `\n VINEXT_CACHE: KVNamespace;` : ""}
|
|
355
280
|
IMAGES: {
|
|
356
281
|
input(stream: ReadableStream): {
|
|
357
282
|
transform(options: Record<string, unknown>): {
|
|
@@ -374,7 +299,11 @@ interface ExecutionContext {
|
|
|
374
299
|
|
|
375
300
|
export default {
|
|
376
301
|
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
|
377
|
-
${
|
|
302
|
+
${hasISR ? ` // Wire up KV-backed ISR cache. The vinext RSC entry automatically
|
|
303
|
+
// registers ctx in ALS so background KV puts use waitUntil — without
|
|
304
|
+
// this every request would return MISS.
|
|
305
|
+
setCacheHandler(new KVCacheHandler(env.VINEXT_CACHE));
|
|
306
|
+
` : ""} const url = new URL(request.url);
|
|
378
307
|
|
|
379
308
|
// Image optimization via Cloudflare Images binding.
|
|
380
309
|
// The parseImageParams validation inside handleImageOptimization
|
|
@@ -399,8 +328,8 @@ ${isrSetup} const url = new URL(request.url);
|
|
|
399
328
|
`;
|
|
400
329
|
}
|
|
401
330
|
/** Generate worker/index.ts for Pages Router */
|
|
402
|
-
|
|
403
|
-
|
|
331
|
+
function generatePagesRouterWorkerEntry() {
|
|
332
|
+
return `/**
|
|
404
333
|
* Cloudflare Worker entry point -- auto-generated by vinext deploy.
|
|
405
334
|
* Edit freely or delete to regenerate on next deploy.
|
|
406
335
|
*/
|
|
@@ -741,39 +670,27 @@ function mergeHeaders(
|
|
|
741
670
|
`;
|
|
742
671
|
}
|
|
743
672
|
/** Generate vite.config.ts for App Router */
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
plugins.push(` // vinext auto-injects @mdx-js/rollup with plugins from next.config`);
|
|
756
|
-
}
|
|
757
|
-
plugins.push(` vinext(),`);
|
|
758
|
-
plugins.push(` cloudflare({
|
|
673
|
+
function generateAppRouterViteConfig(info) {
|
|
674
|
+
const imports = [
|
|
675
|
+
`import { defineConfig } from "vite";`,
|
|
676
|
+
`import vinext from "vinext";`,
|
|
677
|
+
`import { cloudflare } from "@cloudflare/vite-plugin";`
|
|
678
|
+
];
|
|
679
|
+
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
|
|
680
|
+
const plugins = [];
|
|
681
|
+
if (info?.hasMDX) plugins.push(` // vinext auto-injects @mdx-js/rollup with plugins from next.config`);
|
|
682
|
+
plugins.push(` vinext(),`);
|
|
683
|
+
plugins.push(` cloudflare({
|
|
759
684
|
viteEnvironment: {
|
|
760
685
|
name: "rsc",
|
|
761
686
|
childEnvironments: ["ssr"],
|
|
762
687
|
},
|
|
763
688
|
}),`);
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
for (const mod of info.nativeModulesToStub) {
|
|
770
|
-
aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
if (aliases.length > 0) {
|
|
774
|
-
resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
|
|
775
|
-
}
|
|
776
|
-
return `${imports.join("\n")}
|
|
689
|
+
let resolveBlock = "";
|
|
690
|
+
const aliases = [];
|
|
691
|
+
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) for (const mod of info.nativeModulesToStub) aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
|
|
692
|
+
if (aliases.length > 0) resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
|
|
693
|
+
return `${imports.join("\n")}
|
|
777
694
|
|
|
778
695
|
export default defineConfig({
|
|
779
696
|
plugins: [
|
|
@@ -783,28 +700,18 @@ ${plugins.join("\n")}
|
|
|
783
700
|
`;
|
|
784
701
|
}
|
|
785
702
|
/** Generate vite.config.ts for Pages Router */
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
const aliases = [];
|
|
799
|
-
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) {
|
|
800
|
-
for (const mod of info.nativeModulesToStub) {
|
|
801
|
-
aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
if (aliases.length > 0) {
|
|
805
|
-
resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
|
|
806
|
-
}
|
|
807
|
-
return `${imports.join("\n")}
|
|
703
|
+
function generatePagesRouterViteConfig(info) {
|
|
704
|
+
const imports = [
|
|
705
|
+
`import { defineConfig } from "vite";`,
|
|
706
|
+
`import vinext from "vinext";`,
|
|
707
|
+
`import { cloudflare } from "@cloudflare/vite-plugin";`
|
|
708
|
+
];
|
|
709
|
+
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) imports.push(`import path from "node:path";`);
|
|
710
|
+
let resolveBlock = "";
|
|
711
|
+
const aliases = [];
|
|
712
|
+
if (info?.nativeModulesToStub && info.nativeModulesToStub.length > 0) for (const mod of info.nativeModulesToStub) aliases.push(` "${mod}": path.resolve(__dirname, "empty-stub.js"),`);
|
|
713
|
+
if (aliases.length > 0) resolveBlock = `\n resolve: {\n alias: {\n${aliases.join("\n")}\n },\n },`;
|
|
714
|
+
return `${imports.join("\n")}
|
|
808
715
|
|
|
809
716
|
export default defineConfig({
|
|
810
717
|
plugins: [
|
|
@@ -815,282 +722,237 @@ export default defineConfig({
|
|
|
815
722
|
`;
|
|
816
723
|
}
|
|
817
724
|
/**
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
return false;
|
|
830
|
-
}
|
|
725
|
+
* Check if a package is resolvable from a given root directory using
|
|
726
|
+
* Node's module resolution (createRequire). Handles hoisting, pnpm
|
|
727
|
+
* symlinks, monorepos, and Yarn PnP correctly.
|
|
728
|
+
*/
|
|
729
|
+
function isPackageResolvable(root, packageName) {
|
|
730
|
+
try {
|
|
731
|
+
createRequire(path.join(root, "package.json")).resolve(packageName);
|
|
732
|
+
return true;
|
|
733
|
+
} catch {
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
831
736
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
737
|
+
function getMissingDeps(info, _isResolvable = isPackageResolvable) {
|
|
738
|
+
const missing = [];
|
|
739
|
+
if (!info.hasCloudflarePlugin) missing.push({
|
|
740
|
+
name: "@cloudflare/vite-plugin",
|
|
741
|
+
version: "latest"
|
|
742
|
+
});
|
|
743
|
+
if (!info.hasWrangler) missing.push({
|
|
744
|
+
name: "wrangler",
|
|
745
|
+
version: "latest"
|
|
746
|
+
});
|
|
747
|
+
if (!_isResolvable(info.root, "@vitejs/plugin-react")) missing.push({
|
|
748
|
+
name: "@vitejs/plugin-react",
|
|
749
|
+
version: "latest"
|
|
750
|
+
});
|
|
751
|
+
if (info.isAppRouter && !info.hasRscPlugin) missing.push({
|
|
752
|
+
name: "@vitejs/plugin-rsc",
|
|
753
|
+
version: "latest"
|
|
754
|
+
});
|
|
755
|
+
if (info.isAppRouter) {
|
|
756
|
+
if (!_isResolvable(info.root, "react-server-dom-webpack")) missing.push({
|
|
757
|
+
name: "react-server-dom-webpack",
|
|
758
|
+
version: "latest"
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
if (info.hasMDX) {
|
|
762
|
+
if (!_isResolvable(info.root, "@mdx-js/rollup")) missing.push({
|
|
763
|
+
name: "@mdx-js/rollup",
|
|
764
|
+
version: "latest"
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
return missing;
|
|
859
768
|
}
|
|
860
769
|
function installDeps(root, deps) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
stdio: "inherit",
|
|
870
|
-
});
|
|
770
|
+
if (deps.length === 0) return;
|
|
771
|
+
const depSpecs = deps.map((d) => `${d.name}@${d.version}`);
|
|
772
|
+
const [pm, ...pmArgs] = detectPackageManager(root).split(" ");
|
|
773
|
+
console.log(` Installing: ${deps.map((d) => d.name).join(", ")}`);
|
|
774
|
+
execFileSync(pm, [...pmArgs, ...depSpecs], {
|
|
775
|
+
cwd: root,
|
|
776
|
+
stdio: "inherit"
|
|
777
|
+
});
|
|
871
778
|
}
|
|
872
|
-
const detectPackageManager =
|
|
779
|
+
const detectPackageManager = detectPackageManager$1;
|
|
873
780
|
/**
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
catch {
|
|
895
|
-
// unreadable — assume it might be fine
|
|
896
|
-
return true;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
return false;
|
|
781
|
+
* Check whether an existing vite.config file already imports and uses the
|
|
782
|
+
* Cloudflare Vite plugin. This is a heuristic text scan — it doesn't execute
|
|
783
|
+
* the config — so it may produce false negatives for unusual configurations.
|
|
784
|
+
*
|
|
785
|
+
* Returns true if `@cloudflare/vite-plugin` appears to be configured, false
|
|
786
|
+
* if it is missing (meaning the build will fail with "could not resolve
|
|
787
|
+
* virtual:vinext-rsc-entry").
|
|
788
|
+
*/
|
|
789
|
+
function viteConfigHasCloudflarePlugin(root) {
|
|
790
|
+
const candidates = [
|
|
791
|
+
path.join(root, "vite.config.ts"),
|
|
792
|
+
path.join(root, "vite.config.js"),
|
|
793
|
+
path.join(root, "vite.config.mjs")
|
|
794
|
+
];
|
|
795
|
+
for (const candidate of candidates) if (fs.existsSync(candidate)) try {
|
|
796
|
+
return fs.readFileSync(candidate, "utf-8").includes("@cloudflare/vite-plugin");
|
|
797
|
+
} catch {
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
return false;
|
|
901
801
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
path: path.join(info.root, "vite.config.ts"),
|
|
927
|
-
content: viteContent,
|
|
928
|
-
description: "vite.config.ts",
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
return files;
|
|
802
|
+
function getFilesToGenerate(info) {
|
|
803
|
+
const files = [];
|
|
804
|
+
if (!info.hasWranglerConfig) files.push({
|
|
805
|
+
path: path.join(info.root, "wrangler.jsonc"),
|
|
806
|
+
content: generateWranglerConfig(info),
|
|
807
|
+
description: "wrangler.jsonc"
|
|
808
|
+
});
|
|
809
|
+
if (!info.hasWorkerEntry) {
|
|
810
|
+
const workerContent = info.isAppRouter ? generateAppRouterWorkerEntry(info.hasISR) : generatePagesRouterWorkerEntry();
|
|
811
|
+
files.push({
|
|
812
|
+
path: path.join(info.root, "worker", "index.ts"),
|
|
813
|
+
content: workerContent,
|
|
814
|
+
description: "worker/index.ts"
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
if (!info.hasViteConfig) {
|
|
818
|
+
const viteContent = info.isAppRouter ? generateAppRouterViteConfig(info) : generatePagesRouterViteConfig(info);
|
|
819
|
+
files.push({
|
|
820
|
+
path: path.join(info.root, "vite.config.ts"),
|
|
821
|
+
content: viteContent,
|
|
822
|
+
description: "vite.config.ts"
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
return files;
|
|
932
826
|
}
|
|
933
827
|
function writeGeneratedFiles(files) {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
console.log(` Created ${file.description}`);
|
|
941
|
-
}
|
|
828
|
+
for (const file of files) {
|
|
829
|
+
const dir = path.dirname(file.path);
|
|
830
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
831
|
+
fs.writeFileSync(file.path, file.content, "utf-8");
|
|
832
|
+
console.log(` Created ${file.description}`);
|
|
833
|
+
}
|
|
942
834
|
}
|
|
943
|
-
// ─── Build ───────────────────────────────────────────────────────────────────
|
|
944
835
|
async function runBuild(info) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
else {
|
|
957
|
-
await build({ root: info.root });
|
|
958
|
-
}
|
|
836
|
+
console.log("\n Building for Cloudflare Workers...\n");
|
|
837
|
+
let vitePath;
|
|
838
|
+
try {
|
|
839
|
+
vitePath = createRequire(path.join(info.root, "package.json")).resolve("vite");
|
|
840
|
+
} catch {
|
|
841
|
+
vitePath = "vite";
|
|
842
|
+
}
|
|
843
|
+
const { createBuilder, build } = await (vitePath === "vite" ? import(vitePath) : import(pathToFileURL(vitePath).href));
|
|
844
|
+
if (info.isAppRouter) await (await createBuilder({ root: info.root })).buildApp();
|
|
845
|
+
else await build({ root: info.root });
|
|
959
846
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
847
|
+
function buildWranglerDeployArgs(options) {
|
|
848
|
+
const args = ["deploy"];
|
|
849
|
+
const env = options.env || (options.preview ? "preview" : void 0);
|
|
850
|
+
if (env) args.push("--env", env);
|
|
851
|
+
return {
|
|
852
|
+
args,
|
|
853
|
+
env
|
|
854
|
+
};
|
|
967
855
|
}
|
|
968
856
|
function runWranglerDeploy(root, options) {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
console.log("\n Deploying to production...");
|
|
984
|
-
}
|
|
985
|
-
// Use execFileSync to avoid shell injection — args are passed as an array,
|
|
986
|
-
// never interpolated into a shell command string.
|
|
987
|
-
const output = execFileSync(wranglerBin, args, execOpts);
|
|
988
|
-
// Parse the deployed URL from wrangler output
|
|
989
|
-
// Wrangler prints: "Published <name> (version_id)\n https://<name>.<subdomain>.workers.dev"
|
|
990
|
-
const urlMatch = output.match(/https:\/\/[^\s]+\.workers\.dev[^\s]*/);
|
|
991
|
-
const deployedUrl = urlMatch ? urlMatch[0] : null;
|
|
992
|
-
// Also print raw output for transparency
|
|
993
|
-
if (output.trim()) {
|
|
994
|
-
for (const line of output.trim().split("\n")) {
|
|
995
|
-
console.log(` ${line}`);
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
return deployedUrl ?? "(URL not detected in wrangler output)";
|
|
857
|
+
const wranglerBin = findInNodeModules(root, ".bin/wrangler") ?? path.join(root, "node_modules", ".bin", "wrangler");
|
|
858
|
+
const execOpts = {
|
|
859
|
+
cwd: root,
|
|
860
|
+
stdio: "pipe",
|
|
861
|
+
encoding: "utf-8"
|
|
862
|
+
};
|
|
863
|
+
const { args, env } = buildWranglerDeployArgs(options);
|
|
864
|
+
if (env) console.log(`\n Deploying to env: ${env}...`);
|
|
865
|
+
else console.log("\n Deploying to production...");
|
|
866
|
+
const output = execFileSync(wranglerBin, args, execOpts);
|
|
867
|
+
const urlMatch = output.match(/https:\/\/[^\s]+\.workers\.dev[^\s]*/);
|
|
868
|
+
const deployedUrl = urlMatch ? urlMatch[0] : null;
|
|
869
|
+
if (output.trim()) for (const line of output.trim().split("\n")) console.log(` ${line}`);
|
|
870
|
+
return deployedUrl ?? "(URL not detected in wrangler output)";
|
|
999
871
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
});
|
|
1083
|
-
if (tprResult.skipped) {
|
|
1084
|
-
console.log(` TPR: Skipped (${tprResult.skipped})`);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
// Step 7: Deploy via wrangler
|
|
1088
|
-
const url = runWranglerDeploy(root, {
|
|
1089
|
-
preview: options.preview ?? false,
|
|
1090
|
-
env: options.env,
|
|
1091
|
-
});
|
|
1092
|
-
console.log("\n ─────────────────────────────────────────");
|
|
1093
|
-
console.log(` Deployed to: ${url}`);
|
|
1094
|
-
console.log(" ─────────────────────────────────────────\n");
|
|
872
|
+
async function deploy(options) {
|
|
873
|
+
const root = path.resolve(options.root);
|
|
874
|
+
loadDotenv({
|
|
875
|
+
root,
|
|
876
|
+
mode: "production"
|
|
877
|
+
});
|
|
878
|
+
console.log("\n vinext deploy\n");
|
|
879
|
+
const info = detectProject(root);
|
|
880
|
+
if (!info.isAppRouter && !info.isPagesRouter) {
|
|
881
|
+
console.error(" Error: No app/ or pages/ directory found.");
|
|
882
|
+
console.error(" vinext deploy requires a Next.js project with an app/ or pages/ directory");
|
|
883
|
+
console.error(" (also checks src/app/ and src/pages/).\n");
|
|
884
|
+
process.exit(1);
|
|
885
|
+
}
|
|
886
|
+
if (options.name) info.projectName = options.name;
|
|
887
|
+
console.log(` Project: ${info.projectName}`);
|
|
888
|
+
console.log(` Router: ${info.isAppRouter ? "App Router" : "Pages Router"}`);
|
|
889
|
+
console.log(` ISR: ${info.hasISR ? "detected" : "none"}`);
|
|
890
|
+
if (info.isAppRouter) {
|
|
891
|
+
const reactUpgrade = getReactUpgradeDeps(root);
|
|
892
|
+
if (reactUpgrade.length > 0) {
|
|
893
|
+
const [pm, ...pmArgs] = detectPackageManager(root).replace(/ -D$/, "").split(" ");
|
|
894
|
+
console.log(` Upgrading ${reactUpgrade.map((d) => d.replace(/@latest$/, "")).join(", ")}...`);
|
|
895
|
+
execFileSync(pm, [...pmArgs, ...reactUpgrade], {
|
|
896
|
+
cwd: root,
|
|
897
|
+
stdio: "inherit"
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const missingDeps = getMissingDeps(info);
|
|
902
|
+
if (missingDeps.length > 0) {
|
|
903
|
+
console.log();
|
|
904
|
+
installDeps(root, missingDeps);
|
|
905
|
+
const nameOverride = options.name ? info.projectName : void 0;
|
|
906
|
+
Object.assign(info, detectProject(root));
|
|
907
|
+
if (nameOverride) info.projectName = nameOverride;
|
|
908
|
+
}
|
|
909
|
+
if (!info.hasTypeModule) {
|
|
910
|
+
const renamedConfigs = renameCJSConfigs(root);
|
|
911
|
+
for (const [oldName, newName] of renamedConfigs) console.log(` Renamed ${oldName} → ${newName} (CJS → .cjs)`);
|
|
912
|
+
if (ensureESModule(root)) {
|
|
913
|
+
console.log(` Added "type": "module" to package.json`);
|
|
914
|
+
info.hasTypeModule = true;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
const filesToGenerate = getFilesToGenerate(info);
|
|
918
|
+
if (filesToGenerate.length > 0) {
|
|
919
|
+
console.log();
|
|
920
|
+
writeGeneratedFiles(filesToGenerate);
|
|
921
|
+
}
|
|
922
|
+
if (info.hasViteConfig && !viteConfigHasCloudflarePlugin(root)) throw new Error(formatMissingCloudflarePluginError({ isAppRouter: info.isAppRouter }));
|
|
923
|
+
if (options.dryRun) {
|
|
924
|
+
console.log("\n Dry run complete. Files generated but no build or deploy performed.\n");
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (!options.skipBuild) await runBuild(info);
|
|
928
|
+
else console.log("\n Skipping build (--skip-build)");
|
|
929
|
+
{
|
|
930
|
+
const isStaticExport = (await resolveNextConfig(await loadNextConfig(info.root), info.root)).output === "export";
|
|
931
|
+
if (options.prerenderAll || isStaticExport) {
|
|
932
|
+
const label = isStaticExport && !options.prerenderAll ? "Pre-rendering all routes (output: 'export')..." : "Pre-rendering all routes...";
|
|
933
|
+
console.log(`\n ${label}`);
|
|
934
|
+
await runPrerender({ root: info.root });
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (options.experimentalTPR) {
|
|
938
|
+
console.log();
|
|
939
|
+
const tprResult = await runTPR({
|
|
940
|
+
root,
|
|
941
|
+
coverage: Math.max(1, Math.min(100, options.tprCoverage ?? 90)),
|
|
942
|
+
limit: Math.max(1, options.tprLimit ?? 1e3),
|
|
943
|
+
window: Math.max(1, options.tprWindow ?? 24)
|
|
944
|
+
});
|
|
945
|
+
if (tprResult.skipped) console.log(` TPR: Skipped (${tprResult.skipped})`);
|
|
946
|
+
}
|
|
947
|
+
const url = runWranglerDeploy(root, {
|
|
948
|
+
preview: options.preview ?? false,
|
|
949
|
+
env: options.env
|
|
950
|
+
});
|
|
951
|
+
console.log("\n ─────────────────────────────────────────");
|
|
952
|
+
console.log(` Deployed to: ${url}`);
|
|
953
|
+
console.log(" ─────────────────────────────────────────\n");
|
|
1095
954
|
}
|
|
955
|
+
//#endregion
|
|
956
|
+
export { buildWranglerDeployArgs, deploy, detectProject, ensureESModule, formatMissingCloudflarePluginError, generateAppRouterViteConfig, generateAppRouterWorkerEntry, generatePagesRouterViteConfig, generatePagesRouterWorkerEntry, generateWranglerConfig, getFilesToGenerate, getMissingDeps, hasWranglerConfig, isPackageResolvable, parseDeployArgs, renameCJSConfigs, viteConfigHasCloudflarePlugin };
|
|
957
|
+
|
|
1096
958
|
//# sourceMappingURL=deploy.js.map
|