Skip to content

Commit

Permalink
chore: update imports to node16-style imports
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenle committed Apr 18, 2024
1 parent e1d3ae1 commit 7376e27
Show file tree
Hide file tree
Showing 39 changed files with 116 additions and 135 deletions.
2 changes: 1 addition & 1 deletion packages/create-root/src/root-version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// This file is autogenerated by update-root-version.mjs.
export const ROOT_VERSION = '1.0.0-rc.42';
export const ROOT_VERSION = '1.0.3';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {CSS} from './PasswordPage.css';
import {CSS} from './PasswordPage.css.js';

export interface PasswordPageProps {
nonce: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/root-password-protect/src/core/core.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './password';
export * from './password.js';
2 changes: 1 addition & 1 deletion packages/root-password-protect/src/plugin/plugin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Request, Response, NextFunction, Plugin, Server} from '@blinkk/root';
import bodyParser from 'body-parser';
import micromatch from 'micromatch';
import renderToString from 'preact-render-to-string';
import {renderToString} from 'preact-render-to-string';
import {
PasswordPage,
PasswordPageProps,
Expand Down
10 changes: 5 additions & 5 deletions packages/root/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Command} from 'commander';
import {bgGreen, black} from 'kleur/colors';
import {build} from './build';
import {createPackage} from './create-package';
import {dev, createDevServer} from './dev';
import {preview, createPreviewServer} from './preview';
import {start, createProdServer} from './start';
import {build} from './build.js';
import {createPackage} from './create-package.js';
import {dev, createDevServer} from './dev.js';
import {preview, createPreviewServer} from './preview.js';
import {start, createProdServer} from './start.js';

class CliRunner {
private name: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/root/src/cli/create-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
makeDir,
rmDir,
writeJson,
} from '../utils/fsutils';
import {build as rootBuild} from './build';
} from '../utils/fsutils.js';
import {build as rootBuild} from './build.js';

type DeployTarget = 'appengine' | 'firebase';

Expand Down
20 changes: 10 additions & 10 deletions packages/root/src/cli/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import {default as express} from 'express';
import {dim} from 'kleur/colors';
import sirv from 'sirv';

import {RootConfig} from '../core/config';
import {configureServerPlugins} from '../core/plugin';
import {RootConfig} from '../core/config.js';
import {configureServerPlugins} from '../core/plugin.js';
import {Request, Response, NextFunction, Server} from '../core/types.js';
import {hooksMiddleware} from '../middleware/hooks';
import {hooksMiddleware} from '../middleware/hooks.js';
import {
headersMiddleware,
rootProjectMiddleware,
trailingSlashMiddleware,
} from '../middleware/middleware';
import {redirectsMiddleware} from '../middleware/redirects';
import {sessionMiddleware} from '../middleware/session';
} from '../middleware/middleware.js';
import {redirectsMiddleware} from '../middleware/redirects.js';
import {sessionMiddleware} from '../middleware/session.js';
import {ElementGraph} from '../node/element-graph.js';
import {loadBundledConfig} from '../node/load-config';
import {loadBundledConfig} from '../node/load-config.js';
import {
BuildAssetManifest,
BuildAssetMap,
} from '../render/asset-map/build-asset-map';
import {fileExists, loadJson} from '../utils/fsutils';
import {randString} from '../utils/rand';
} from '../render/asset-map/build-asset-map.js';
import {fileExists, loadJson} from '../utils/fsutils.js';
import {randString} from '../utils/rand.js';

type RenderModule = typeof import('../render/render.js');

Expand Down
22 changes: 11 additions & 11 deletions packages/root/src/cli/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import {default as express} from 'express';
import {dim} from 'kleur/colors';
import sirv from 'sirv';

import {RootConfig} from '../core/config';
import {configureServerPlugins} from '../core/plugin';
import {RootConfig} from '../core/config.js';
import {configureServerPlugins} from '../core/plugin.js';
import {Request, Response, NextFunction, Server} from '../core/types.js';
import {hooksMiddleware} from '../middleware/hooks';
import {hooksMiddleware} from '../middleware/hooks.js';
import {
headersMiddleware,
rootProjectMiddleware,
trailingSlashMiddleware,
} from '../middleware/middleware';
import {redirectsMiddleware} from '../middleware/redirects';
import {sessionMiddleware} from '../middleware/session';
import {ElementGraph} from '../node/element-graph';
import {loadBundledConfig} from '../node/load-config';
} from '../middleware/middleware.js';
import {redirectsMiddleware} from '../middleware/redirects.js';
import {sessionMiddleware} from '../middleware/session.js';
import {ElementGraph} from '../node/element-graph.js';
import {loadBundledConfig} from '../node/load-config.js';
import {
BuildAssetManifest,
BuildAssetMap,
} from '../render/asset-map/build-asset-map';
import {fileExists, loadJson} from '../utils/fsutils';
import {randString} from '../utils/rand';
} from '../render/asset-map/build-asset-map.js';
import {fileExists, loadJson} from '../utils/fsutils.js';
import {randString} from '../utils/rand.js';

type RenderModule = typeof import('../render/render.js');

Expand Down
3 changes: 1 addition & 2 deletions packages/root/src/core/components/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ComponentChildren, FunctionalComponent} from 'preact';
import {useContext} from 'preact/hooks';

import {HTML_CONTEXT} from './Html';
import {HTML_CONTEXT} from './Html.js';

export type BodyProps = preact.JSX.HTMLAttributes<HTMLBodyElement> & {
children?: ComponentChildren;
Expand Down
3 changes: 1 addition & 2 deletions packages/root/src/core/components/Head.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ComponentChildren, FunctionalComponent} from 'preact';
import {useContext} from 'preact/hooks';

import {HTML_CONTEXT} from './Html';
import {HTML_CONTEXT} from './Html.js';

export type HeadProps = preact.JSX.HTMLAttributes<HTMLHeadElement> & {
children?: ComponentChildren;
Expand Down
3 changes: 1 addition & 2 deletions packages/root/src/core/components/Script.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {FunctionalComponent} from 'preact';
import {useContext} from 'preact/hooks';

import {HTML_CONTEXT} from './Html';
import {HTML_CONTEXT} from './Html.js';

export type ScriptProps = preact.JSX.HTMLAttributes<HTMLScriptElement>;

Expand Down
10 changes: 4 additions & 6 deletions packages/root/src/core/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {UserConfig as ViteUserConfig} from 'vite';

import {HtmlMinifyOptions} from '../render/html-minify';
import {HtmlPrettyOptions} from '../render/html-pretty';

import {Plugin} from './plugin';
import {RequestMiddleware} from './types';
import {HtmlMinifyOptions} from '../render/html-minify.js';
import {HtmlPrettyOptions} from '../render/html-pretty.js';
import {Plugin} from './plugin.js';
import {RequestMiddleware} from './types.js';

export interface RootUserConfig {
/**
Expand Down
20 changes: 10 additions & 10 deletions packages/root/src/core/core.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export * from './config';
export {Body} from './components/Body';
export {Head} from './components/Head';
export {Html, HTML_CONTEXT} from './components/Html';
export {Script} from './components/Script';
export * from './config.js';
export {Body} from './components/Body.js';
export {Head} from './components/Head.js';
export {Html, HTML_CONTEXT} from './components/Html.js';
export {Script} from './components/Script.js';
export {
I18nContext,
useI18nContext,
getTranslations,
} from './hooks/useI18nContext';
export {RequestContext, useRequestContext} from './hooks/useRequestContext';
export {useTranslations} from './hooks/useTranslations';
export * from './plugin';
export * from './types';
} from './hooks/useI18nContext.js';
export {RequestContext, useRequestContext} from './hooks/useRequestContext.js';
export {useTranslations} from './hooks/useTranslations.js';
export * from './plugin.js';
export * from './types.js';
1 change: 0 additions & 1 deletion packages/root/src/core/hooks/useI18nContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'node:path';

import {createContext} from 'preact';
import {useContext} from 'preact/hooks';

Expand Down
3 changes: 1 addition & 2 deletions packages/root/src/core/hooks/useRequestContext.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {createContext} from 'preact';
import {useContext} from 'preact/hooks';

import {Route} from '../types';
import {Route} from '../types.js';

export interface RequestContext {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/root/src/core/hooks/useTranslations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {I18nContext, useI18nContext} from './useI18nContext';
import {I18nContext, useI18nContext} from './useI18nContext.js';

/**
* A hook that returns a function that can be used to translate a string, and
Expand Down
5 changes: 2 additions & 3 deletions packages/root/src/core/pages/DevErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Request, Route, RouteParams} from '../types';

import {ErrorPage} from './ErrorPage';
import {Request, Route, RouteParams} from '../types.js';
import {ErrorPage} from './ErrorPage.js';

interface DevErrorPageProps {
req: Request;
Expand Down
5 changes: 2 additions & 3 deletions packages/root/src/core/pages/DevNotFoundPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Request, Route} from '../types';

import {ErrorPage} from './ErrorPage';
import {Request, Route} from '../types.js';
import {ErrorPage} from './ErrorPage.js';

interface DevNotFoundPageProps {
req: Request;
Expand Down
5 changes: 2 additions & 3 deletions packages/root/src/core/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {ViteDevServer, PluginOption as VitePlugin} from 'vite';

import {RootConfig} from './config';
import {Server} from './types';
import {RootConfig} from './config.js';
import {Server} from './types.js';

type MaybePromise<T> = T | Promise<T>;

Expand Down
10 changes: 4 additions & 6 deletions packages/root/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import {
} from 'express';
import {ComponentType} from 'preact';
import {ViteDevServer} from 'vite';

import {Hooks} from '../middleware/hooks';
import {Session} from '../middleware/session';
import {Renderer} from '../render/render';

import {RootConfig} from './config';
import {Hooks} from '../middleware/hooks.js';
import {Session} from '../middleware/session.js';
import {Renderer} from '../render/render.js';
import {RootConfig} from './config.js';

/**
* Param values from the route, e.g. a route like `/route/[slug].tsx` will pass
Expand Down
2 changes: 1 addition & 1 deletion packages/root/src/functions/functions.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './server';
export * from './server.js';
4 changes: 2 additions & 2 deletions packages/root/src/functions/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import {HttpsOptions, onRequest} from 'firebase-functions/v2/https';
import {createPreviewServer, createProdServer} from '../cli/cli';
import {Server} from '../core/types';
import {createPreviewServer, createProdServer} from '../cli/cli.js';
import {Server} from '../core/types.js';

export interface ProdServerOptions {
rootDir?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/root/src/middleware/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import micromatch from 'micromatch';
import {RootConfig} from '../core/config';
import {Request, Response, NextFunction} from '../core/types';
import {RootConfig} from '../core/config.js';
import {Request, Response, NextFunction} from '../core/types.js';

/**
* Middleware that injects the root.js project config into the request context.
Expand Down
2 changes: 1 addition & 1 deletion packages/root/src/middleware/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Request, Response, NextFunction} from '../core/types';
import {Request, Response, NextFunction} from '../core/types.js';

export function hooksMiddleware() {
return (req: Request, res: Response, next: NextFunction) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/root/src/middleware/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './common';
export * from './multipart';
export * from './session';
export * from './common.js';
export * from './multipart.js';
export * from './session.js';
2 changes: 1 addition & 1 deletion packages/root/src/middleware/multipart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import busboy from 'busboy';
import {RequestHandler} from 'express';
import {Request, Response, NextFunction, MultipartFile} from '../core/types';
import {Request, Response, NextFunction, MultipartFile} from '../core/types.js';

const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB

Expand Down
6 changes: 3 additions & 3 deletions packages/root/src/middleware/redirects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {RootRedirectConfig} from '../core/config';
import {NextFunction, Request, Response} from '../core/types';
import {RouteTrie} from '../render/route-trie';
import {RootRedirectConfig} from '../core/config.js';
import {NextFunction, Request, Response} from '../core/types.js';
import {RouteTrie} from '../render/route-trie.js';

export interface RedirectsMiddlewareOptions {
redirects: RootRedirectConfig[];
Expand Down
2 changes: 1 addition & 1 deletion packages/root/src/middleware/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NextFunction, Request, Response} from '../core/types';
import {NextFunction, Request, Response} from '../core/types.js';

export const SESSION_COOKIE = '__session';

Expand Down
8 changes: 3 additions & 5 deletions packages/root/src/node/element-graph.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import fs from 'node:fs';
import path from 'node:path';

import glob from 'tiny-glob';
import {searchForWorkspaceRoot} from 'vite';

import {RootConfig} from '../core/config';
import {isValidTagName, parseTagNames} from '../utils/elements';
import {directoryContains, isDirectory, isJsFile} from '../utils/fsutils';
import {RootConfig} from '../core/config.js';
import {isValidTagName, parseTagNames} from '../utils/elements.js';
import {directoryContains, isDirectory, isJsFile} from '../utils/fsutils.js';

interface ElementSourceFile {
/** Full file path. */
Expand Down
4 changes: 2 additions & 2 deletions packages/root/src/node/load-config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'node:path';
import {bundleRequire} from 'bundle-require';
import {build} from 'esbuild';
import {RootConfig} from '../core/config';
import {fileExists, loadJson} from '../utils/fsutils';
import {RootConfig} from '../core/config.js';
import {fileExists, loadJson} from '../utils/fsutils.js';

export interface ConfigOptions {
command: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/root/src/node/node.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './load-config';
export * from './vite';
export * from './load-config.js';
export * from './vite.js';
11 changes: 4 additions & 7 deletions packages/root/src/render/asset-map/build-asset-map.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import fs from 'node:fs';
import path from 'node:path';

import {Manifest} from 'vite';

import {RootConfig} from '../../core/config';
import {ElementGraph} from '../../node/element-graph';
import {isJsFile} from '../../utils/fsutils';

import {Asset, AssetMap} from './asset-map';
import {RootConfig} from '../../core/config.js';
import {ElementGraph} from '../../node/element-graph.js';
import {isJsFile} from '../../utils/fsutils.js';
import {Asset, AssetMap} from './asset-map.js';

export type BuildAssetManifest = Record<
string,
Expand Down
9 changes: 3 additions & 6 deletions packages/root/src/render/asset-map/dev-asset-map.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import path from 'node:path';

import {ModuleGraph, ModuleNode, searchForWorkspaceRoot} from 'vite';

import {RootConfig} from '../../core/config';
import {directoryContains} from '../../utils/fsutils';

import {Asset, AssetMap} from './asset-map';
import {RootConfig} from '../../core/config.js';
import {directoryContains} from '../../utils/fsutils.js';
import {Asset, AssetMap} from './asset-map.js';

export class DevServerAssetMap implements AssetMap {
private rootConfig: RootConfig;
Expand Down
3 changes: 1 addition & 2 deletions packages/root/src/render/html-minify.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {expect, test} from 'vitest';

import {htmlMinify} from './html-minify';
import {htmlMinify} from './html-minify.js';

test('minify html', async () => {
const input = `
Expand Down
4 changes: 2 additions & 2 deletions packages/root/src/render/i18n-fallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* https://firebase.google.com/docs/hosting/i18n-rewrites
*/

import {Request} from '../core/types';
import {parseAcceptLanguage} from './accept-language';
import {Request} from '../core/types.js';
import {parseAcceptLanguage} from './accept-language.js';

export const UNKNOWN_COUNTRY = 'zz';
export const ES_419_COUNTRIES = [
Expand Down
Loading

0 comments on commit 7376e27

Please sign in to comment.