Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use moduleResolution Bundler and remove .js extesion #1955

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-react-ts/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import express from 'express'
import compression from 'compression'
import { renderPage } from 'vike/server'
import { root } from './root.js'
import { root } from './root'
const isProduction = process.env.NODE_ENV === 'production'

startServer()
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-react/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import express from 'express'
import compression from 'compression'
import { renderPage } from 'vike/server'
import { root } from './root.js'
import { root } from './root'
const isProduction = process.env.NODE_ENV === 'production'

startServer()
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-vue-ts/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import express from 'express'
import compression from 'compression'
import { renderPage } from 'vike/server'
import { root } from './root.js'
import { root } from './root'
const isProduction = process.env.NODE_ENV === 'production'

startServer()
Expand Down
2 changes: 1 addition & 1 deletion boilerplates/boilerplate-vue/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import express from 'express'
import compression from 'compression'
import { renderPage } from 'vike/server'
import { root } from './root.js'
import { root } from './root'
const isProduction = process.env.NODE_ENV === 'production'

startServer()
Expand Down
12 changes: 6 additions & 6 deletions vike/__internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig }
// Internals needed by nitedani's experimental implementation of vike-telefunc
export { getPageFilesAllSafe }

import { route as routeInternal, type PageRoutes } from '../shared/route/index.js'
import { getPageFilesAll, type PageFile } from '../shared/getPageFiles.js'
import { getGlobalContext, initGlobalContext_getGlobalContextAsync } from '../node/runtime/globalContext.js'
import { handleNodeEnv_vitePluginVercel } from '../utils/assertNodeEnv.js'
import { getRenderContext } from '../node/runtime/renderPage/renderPageAlreadyRouted.js'
import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js'
import { route as routeInternal, type PageRoutes } from '../shared/route/index'
import { getPageFilesAll, type PageFile } from '../shared/getPageFiles'
import { getGlobalContext, initGlobalContext_getGlobalContextAsync } from '../node/runtime/globalContext'
import { handleNodeEnv_vitePluginVercel } from '../utils/assertNodeEnv'
import { getRenderContext } from '../node/runtime/renderPage/renderPageAlreadyRouted'
import { PageConfigRuntime } from '../shared/page-configs/PageConfig'

/**
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel}
Expand Down
10 changes: 5 additions & 5 deletions vike/client/client-routing-runtime/createPageContext.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { createPageContext }

import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed.js'
import { getPageFilesAll } from '../../shared/getPageFiles.js'
import { loadPageRoutes } from '../../shared/route/loadPageRoutes.js'
import { getBaseServer } from './getBaseServer.js'
import { assert, isBaseServer, PromiseType, getGlobalObject, objectAssign } from './utils.js'
import { getPageContextUrlComputed } from '../../shared/getPageContextUrlComputed'
import { getPageFilesAll } from '../../shared/getPageFiles'
import { loadPageRoutes } from '../../shared/route/loadPageRoutes'
import { getBaseServer } from './getBaseServer'
import { assert, isBaseServer, PromiseType, getGlobalObject, objectAssign } from './utils'
const globalObject = getGlobalObject<{
pageFilesData?: PromiseType<ReturnType<typeof getPageFilesAll>>
}>('createPageContext.ts', {})
Expand Down
8 changes: 4 additions & 4 deletions vike/client/client-routing-runtime/entry.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assertClientRouting } from '../../utils/assertRoutingType.js'
import { assertClientRouting } from '../../utils/assertRoutingType'
assertClientRouting()

import './pageFiles'
import { initClientRouter } from './initClientRouter.js'
import { assertSingleInstance_onClientEntryClientRouting } from './utils.js'
import { removeFoucBuster } from '../shared/removeFoucBuster.js'
import { initClientRouter } from './initClientRouter'
import { assertSingleInstance_onClientEntryClientRouting } from './utils'
import { removeFoucBuster } from '../shared/removeFoucBuster'
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
const isProd: boolean = import.meta.env.PROD
assertSingleInstance_onClientEntryClientRouting(isProd)
Expand Down
2 changes: 1 addition & 1 deletion vike/client/client-routing-runtime/getBaseServer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { getBaseServer }

import { assert } from '../server-routing-runtime/utils.js'
import { assert } from '../server-routing-runtime/utils'

function getBaseServer(): string {
// @ts-ignore Since dist/cjs/client/ is never used, we can ignore this error.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { removeBuiltInOverrides }

import { assert, assertWarning } from '../utils.js'
import { assert, assertWarning } from '../utils'

const BUILT_IN_CLIENT_ROUTER = ['urlPathname', 'urlParsed'] as const
const BUILT_IN_CLIENT = ['Page', 'pageExports', 'exports'] as const
Expand Down
4 changes: 2 additions & 2 deletions vike/client/client-routing-runtime/getPageContextCurrent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { setPageContextCurrent }
export { getPageContextCurrent }

import { getGlobalObject } from './utils.js'
import type { PageContextExports } from '../../shared/getPageFiles.js'
import { getGlobalObject } from './utils'
import type { PageContextExports } from '../../shared/getPageFiles'

type PageContextCurrent = PageContextExports & {
urlPathname: string
Expand Down
32 changes: 16 additions & 16 deletions vike/client/client-routing-runtime/getPageContextFromHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ import {
executeHook,
isObject,
getGlobalObject
} from './utils.js'
} from './utils'
import { parse } from '@brillout/json-serializer/parse'
import { getPageContextSerializedInHtml } from '../shared/getPageContextSerializedInHtml.js'
import type { PageContextExports, PageFile } from '../../shared/getPageFiles.js'
import { analyzePageServerSide } from '../../shared/getPageFiles/analyzePageServerSide.js'
import { getHook } from '../../shared/hooks/getHook.js'
import { preparePageContextForUserConsumptionClientSide } from '../shared/preparePageContextForUserConsumptionClientSide.js'
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js'
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js'
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js'
import { getPageConfig } from '../../shared/page-configs/helpers.js'
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValue.js'
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js'
import { executeGuardHook } from '../../shared/route/executeGuardHook.js'
import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js'
import { pageContextInitIsPassedToClient } from '../../shared/misc/pageContextInitIsPassedToClient.js'
import { isServerSideError } from '../../shared/misc/isServerSideError.js'
import { getPageContextSerializedInHtml } from '../shared/getPageContextSerializedInHtml'
import type { PageContextExports, PageFile } from '../../shared/getPageFiles'
import { analyzePageServerSide } from '../../shared/getPageFiles/analyzePageServerSide'
import { getHook } from '../../shared/hooks/getHook'
import { preparePageContextForUserConsumptionClientSide } from '../shared/preparePageContextForUserConsumptionClientSide'
import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides'
import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl'
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig'
import { getPageConfig } from '../../shared/page-configs/helpers'
import { getConfigValueRuntime } from '../../shared/page-configs/getConfigValue'
import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn'
import { executeGuardHook } from '../../shared/route/executeGuardHook'
import { AbortRender, isAbortPageContext } from '../../shared/route/abort'
import { pageContextInitIsPassedToClient } from '../../shared/misc/pageContextInitIsPassedToClient'
import { isServerSideError } from '../../shared/misc/isServerSideError'
const globalObject = getGlobalObject<{ pageContextInitIsPassedToClient?: true }>('router/getPageContext.ts', {})

// TODO/eventually: rename
Expand Down
2 changes: 1 addition & 1 deletion vike/client/client-routing-runtime/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { saveScrollPosition }
export type { HistoryInfo }
export type { ScrollPosition }

import { assert, assertUsage, getCurrentUrl, getGlobalObject, hasProp, isObject } from './utils.js'
import { assert, assertUsage, getCurrentUrl, getGlobalObject, hasProp, isObject } from './utils'

init()
const globalObject = getGlobalObject('history.ts', { previous: getHistoryInfo() })
Expand Down
10 changes: 5 additions & 5 deletions vike/client/client-routing-runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
// import { navigate, prefetch } from 'vike'
// Use package.json#exports to make the imports isomorphic.

export { navigate, reload } from './navigate.js'
export { prefetch } from './prefetch.js'
export { onPopState } from './initOnPopState.js'
export { PROJECT_VERSION as version } from './utils.js'
export { navigate, reload } from './navigate'
export { prefetch } from './prefetch'
export { onPopState } from './initOnPopState'
export { PROJECT_VERSION as version } from './utils'

// TODO/v1-release: remove this
import type { PageContextBuiltInClientWithClientRouting } from '../../shared/types.js'
import type { PageContextBuiltInClientWithClientRouting } from '../../shared/types'
/** @deprecated
* Replace:
* ```
Expand Down
14 changes: 7 additions & 7 deletions vike/client/client-routing-runtime/initClientRouter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export { initClientRouter }

import { assert } from './utils.js'
import { getRenderCount, renderPageClientSide } from './renderPageClientSide.js'
import { initOnPopState } from './initOnPopState.js'
import { initOnLinkClick } from './initOnLinkClick.js'
import { setupNativeScrollRestoration } from './scrollRestoration.js'
import { autoSaveScrollPosition } from './setScrollPosition.js'
import { initLinkPrefetchHandlers } from './prefetch.js'
import { assert } from './utils'
import { getRenderCount, renderPageClientSide } from './renderPageClientSide'
import { initOnPopState } from './initOnPopState'
import { initOnLinkClick } from './initOnLinkClick'
import { setupNativeScrollRestoration } from './scrollRestoration'
import { autoSaveScrollPosition } from './setScrollPosition'
import { initLinkPrefetchHandlers } from './prefetch'

async function initClientRouter() {
// Init navigation history and scroll restoration
Expand Down
8 changes: 4 additions & 4 deletions vike/client/client-routing-runtime/initOnLinkClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

export { initOnLinkClick }

import { assert } from './utils.js'
import { skipLink } from './skipLink.js'
import { renderPageClientSide } from './renderPageClientSide.js'
import type { ScrollTarget } from './setScrollPosition.js'
import { assert } from './utils'
import { skipLink } from './skipLink'
import { renderPageClientSide } from './renderPageClientSide'
import type { ScrollTarget } from './setScrollPosition'

function initOnLinkClick() {
document.addEventListener('click', handler)
Expand Down
8 changes: 4 additions & 4 deletions vike/client/client-routing-runtime/initOnPopState.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { initOnPopState }
export { onPopState }

import { assertWarning, getGlobalObject } from './utils.js'
import { onPopStateBegin, type HistoryInfo } from './history.js'
import { renderPageClientSide } from './renderPageClientSide.js'
import { type ScrollTarget, setScrollPosition } from './setScrollPosition.js'
import { assertWarning, getGlobalObject } from './utils'
import { onPopStateBegin, type HistoryInfo } from './history'
import { renderPageClientSide } from './renderPageClientSide'
import { type ScrollTarget, setScrollPosition } from './setScrollPosition'

const globalObject = getGlobalObject('initOnPopState.ts', { listeners: [] as Listener[] })

Expand Down
10 changes: 5 additions & 5 deletions vike/client/client-routing-runtime/isClientSideRoutable.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { isClientSideRoutable }

import { analyzePageClientSideInit } from '../../shared/getPageFiles/analyzePageClientSide.js'
import { findPageConfig } from '../../shared/page-configs/findPageConfig.js'
import { analyzeClientSide } from '../../shared/getPageFiles/analyzeClientSide.js'
import type { PageFile } from '../../shared/getPageFiles.js'
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js'
import { analyzePageClientSideInit } from '../../shared/getPageFiles/analyzePageClientSide'
import { findPageConfig } from '../../shared/page-configs/findPageConfig'
import { analyzeClientSide } from '../../shared/getPageFiles/analyzeClientSide'
import type { PageFile } from '../../shared/getPageFiles'
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig'

type PageContextPageFiles = {
_pageFilesAll: PageFile[]
Expand Down
8 changes: 4 additions & 4 deletions vike/client/client-routing-runtime/navigate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export { navigate }
export { reload }

import { normalizeUrlArgument } from './normalizeUrlArgument.js'
import { firstRenderStartPromise, renderPageClientSide } from './renderPageClientSide.js'
import type { ScrollTarget } from './setScrollPosition.js'
import { assertClientRouting, getCurrentUrl } from './utils.js'
import { normalizeUrlArgument } from './normalizeUrlArgument'
import { firstRenderStartPromise, renderPageClientSide } from './renderPageClientSide'
import type { ScrollTarget } from './setScrollPosition'
import { assertClientRouting, getCurrentUrl } from './utils'

assertClientRouting()

Expand Down
2 changes: 1 addition & 1 deletion vike/client/client-routing-runtime/normalizeUrlArgument.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { normalizeUrlArgument }

import { assertUsage, isUrl, isUrlPathnameRelative } from './utils.js'
import { assertUsage, isUrl, isUrlPathnameRelative } from './utils'

function normalizeUrlArgument(url: string, fnName: 'prefetch' | 'navigate'): string {
// Succinct error message to save client-side KBs
Expand Down
4 changes: 2 additions & 2 deletions vike/client/client-routing-runtime/onLoad.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { onLoad }

import { assertIsBrowser } from '../../utils/assertIsBrowser.js'
import { assertClientRouting } from '../../utils/assertRoutingType.js'
import { assertIsBrowser } from '../../utils/assertIsBrowser'
import { assertClientRouting } from '../../utils/assertRoutingType'

function onLoad() {
assertIsBrowser()
Expand Down
2 changes: 1 addition & 1 deletion vike/client/client-routing-runtime/pageFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setPageFiles } from '../../shared/getPageFiles.js'
import { setPageFiles } from '../../shared/getPageFiles'
// @ts-ignore
import * as pageFilesExports from 'virtual:vike:importUserCode:client:client-routing'
setPageFiles(pageFilesExports)
28 changes: 14 additions & 14 deletions vike/client/client-routing-runtime/prefetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ import {
getGlobalObject,
hasProp,
objectAssign
} from './utils.js'
} from './utils'
import {
type PageContextUserFiles,
isErrorFetchingStaticAssets,
loadUserFilesClientSide
} from '../shared/loadUserFilesClientSide.js'
import { skipLink } from './skipLink.js'
import { disableClientRouting } from './renderPageClientSide.js'
import { isClientSideRoutable } from './isClientSideRoutable.js'
import { createPageContext } from './createPageContext.js'
import { route, type PageContextFromRoute } from '../../shared/route/index.js'
import { noRouteMatch } from '../../shared/route/noRouteMatch.js'
import { type PageContextFromServerHooks, getPageContextFromServerHooks } from './getPageContextFromHooks.js'
import type { PageContextExports, PageFile } from '../../shared/getPageFiles.js'
import { type PageConfigRuntime } from '../../shared/page-configs/PageConfig.js'
import { getPageContextCurrent } from './getPageContextCurrent.js'
} from '../shared/loadUserFilesClientSide'
import { skipLink } from './skipLink'
import { disableClientRouting } from './renderPageClientSide'
import { isClientSideRoutable } from './isClientSideRoutable'
import { createPageContext } from './createPageContext'
import { route, type PageContextFromRoute } from '../../shared/route/index'
import { noRouteMatch } from '../../shared/route/noRouteMatch'
import { type PageContextFromServerHooks, getPageContextFromServerHooks } from './getPageContextFromHooks'
import type { PageContextExports, PageFile } from '../../shared/getPageFiles'
import { type PageConfigRuntime } from '../../shared/page-configs/PageConfig'
import { getPageContextCurrent } from './getPageContextCurrent'
import {
PAGE_CONTEXT_MAX_AGE_DEFAULT,
type PrefetchSettingResolved,
getPrefetchSettings
} from './prefetch/getPrefetchSettings.js'
} from './prefetch/getPrefetchSettings'
import pc from '@brillout/picocolors'
import { normalizeUrlArgument } from './normalizeUrlArgument.js'
import { normalizeUrlArgument } from './normalizeUrlArgument'

assertClientRouting()
const globalObject = getGlobalObject('prefetch.ts', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export { getPrefetchSettings }
export { PAGE_CONTEXT_MAX_AGE_DEFAULT }
export type { PrefetchSettingResolved }

import { assertUsage, assertInfo } from '../utils.js'
import type { PageContextExports } from '../../../shared/getPageFiles.js'
import type { PrefetchSetting, PrefetchStaticAssets } from './PrefetchSetting.js'
import { assertUsage, assertInfo } from '../utils'
import type { PageContextExports } from '../../../shared/getPageFiles'
import type { PrefetchSetting, PrefetchStaticAssets } from './PrefetchSetting'

// TODO/pageContext-prefetch: Make it `Infinity` for pre-rendered pages.
const PAGE_CONTEXT_MAX_AGE_DEFAULT = 5000
Expand Down
Loading
Loading