Added new_site as a raw tailwind+html site; initialized npm modules; demo template
This commit is contained in:
34
new_site/node_modules/jiti/lib/jiti-cli.mjs
generated
vendored
Executable file
34
new_site/node_modules/jiti/lib/jiti-cli.mjs
generated
vendored
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { resolve } from "node:path";
|
||||
import nodeModule from "node:module";
|
||||
|
||||
const script = process.argv.splice(2, 1)[0];
|
||||
|
||||
if (!script) {
|
||||
console.error("Usage: jiti <path> [...arguments]");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// https://nodejs.org/api/module.html#moduleenablecompilecachecachedir
|
||||
// https://github.com/nodejs/node/pull/54501
|
||||
if (nodeModule.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
|
||||
try {
|
||||
nodeModule.enableCompileCache();
|
||||
} catch {
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
const pwd = process.cwd();
|
||||
|
||||
const { createJiti } = await import("./jiti.cjs");
|
||||
|
||||
const jiti = createJiti(pwd);
|
||||
|
||||
const resolved = (process.argv[1] = jiti.resolve(resolve(pwd, script)));
|
||||
|
||||
await jiti.import(resolved).catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
117
new_site/node_modules/jiti/lib/jiti-hooks.mjs
generated
vendored
Normal file
117
new_site/node_modules/jiti/lib/jiti-hooks.mjs
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { existsSync } from "node:fs";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { isBuiltin } from "node:module";
|
||||
import { createJiti } from "./jiti.mjs";
|
||||
|
||||
let jiti;
|
||||
|
||||
// https://nodejs.org/api/module.html#initialize
|
||||
export async function initialize() {
|
||||
jiti = createJiti();
|
||||
}
|
||||
|
||||
// https://nodejs.org/api/module.html#resolvespecifier-context-nextresolve
|
||||
export async function resolve(specifier, context, nextResolve) {
|
||||
if (_shouldSkip(specifier)) {
|
||||
return nextResolve(specifier, context);
|
||||
}
|
||||
const resolvedPath = jiti.esmResolve(specifier, {
|
||||
parentURL: context?.parentURL,
|
||||
conditions: context?.conditions,
|
||||
});
|
||||
return {
|
||||
url: resolvedPath,
|
||||
shortCircuit: true,
|
||||
};
|
||||
}
|
||||
|
||||
// https://nodejs.org/api/module.html#loadurl-context-nextload
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (_shouldSkip(url)) {
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
|
||||
const filename = fileURLToPath(url);
|
||||
|
||||
if (url.endsWith(".js")) {
|
||||
const pkg = await _findClosestPackageJson(dirname(filename));
|
||||
if (pkg && pkg.type === "module") {
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
}
|
||||
|
||||
const rawSource = await readFile(filename, "utf8");
|
||||
|
||||
if (url.endsWith(".json")) {
|
||||
return {
|
||||
source: `export default ${rawSource}`,
|
||||
format: "module",
|
||||
shortCircuit: true,
|
||||
};
|
||||
}
|
||||
|
||||
const transpiledSource = jiti.transform({
|
||||
source: rawSource,
|
||||
filename: filename,
|
||||
ts: url.endsWith("ts"),
|
||||
retainLines: true,
|
||||
async: true,
|
||||
jsx: jiti.options.jsx,
|
||||
});
|
||||
|
||||
if (url.endsWith(".js") && !transpiledSource.includes("jitiImport")) {
|
||||
return {
|
||||
source: transpiledSource,
|
||||
format: "commonjs",
|
||||
shortCircuit: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
source: _wrapSource(transpiledSource, filename),
|
||||
format: "module",
|
||||
shortCircuit: true,
|
||||
};
|
||||
}
|
||||
|
||||
function _wrapSource(source, filename) {
|
||||
const _jitiPath = new URL("jiti.mjs", import.meta.url).href;
|
||||
return /*js*/ `import { createJiti as __createJiti__ } from ${JSON.stringify(_jitiPath)};async function _module(exports, require, module, __filename, __dirname, jitiImport) { ${source}\n};
|
||||
// GENERATED BY JITI ESM LOADER
|
||||
const filename = ${JSON.stringify(filename)};
|
||||
const dirname = ${JSON.stringify(dirname(filename))};
|
||||
const jiti = __createJiti__(filename);
|
||||
const module = { exports: Object.create(null) };
|
||||
await _module(module.exports, jiti, module, filename, dirname, jiti.import);
|
||||
if (module.exports && module.exports.__JITI_ERROR__) {
|
||||
const { filename, line, column, code, message } =
|
||||
module.exports.__JITI_ERROR__;
|
||||
const loc = [filename, line, column].join(':');
|
||||
const err = new Error(code + ": " + message + " " + loc);
|
||||
Error.captureStackTrace(err, _module);
|
||||
throw err;
|
||||
}
|
||||
export default module.exports;
|
||||
`;
|
||||
}
|
||||
|
||||
function _shouldSkip(url) {
|
||||
return (
|
||||
!jiti ||
|
||||
url.endsWith(".mjs") ||
|
||||
url.endsWith(".cjs") ||
|
||||
(!url.startsWith("./") && !url.startsWith("file://")) ||
|
||||
isBuiltin(url)
|
||||
);
|
||||
}
|
||||
|
||||
async function _findClosestPackageJson(dir) {
|
||||
if (dir === "/") return null;
|
||||
const packageJsonPath = join(dir, "package.json");
|
||||
if (existsSync(packageJsonPath)) {
|
||||
return JSON.parse(await readFile(packageJsonPath, "utf8"));
|
||||
}
|
||||
return _findClosestPackageJson(dirname(dir));
|
||||
}
|
121
new_site/node_modules/jiti/lib/jiti-native.mjs
generated
vendored
Normal file
121
new_site/node_modules/jiti/lib/jiti-native.mjs
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @typedef {import('./types').Jiti} Jiti
|
||||
* @typedef {import('./types').JitiOptions} JitiOptions
|
||||
*/
|
||||
|
||||
const isDeno = "Deno" in globalThis;
|
||||
|
||||
/**
|
||||
* @param {string|URL} [parentURL]
|
||||
* @param {JitiOptions} [jitiOptions]
|
||||
* @returns {Jiti}
|
||||
*/
|
||||
export function createJiti(parentURL, jitiOptions) {
|
||||
parentURL = normalizeParentURL(parentURL);
|
||||
|
||||
/** @type {Jiti} */
|
||||
function jiti() {
|
||||
throw unsupportedError(
|
||||
"`jiti()` is not supported in native mode, use `jiti.import()` instead.",
|
||||
);
|
||||
}
|
||||
|
||||
jiti.resolve = () => {
|
||||
throw unsupportedError("`jiti.resolve()` is not supported in native mode.");
|
||||
};
|
||||
|
||||
jiti.esmResolve = (id, opts) => {
|
||||
try {
|
||||
const importMeta = jitiOptions?.importMeta || import.meta;
|
||||
if (isDeno) {
|
||||
// Deno throws TypeError: Invalid arguments when passing parentURL
|
||||
return importMeta.resolve(id);
|
||||
}
|
||||
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
||||
return importMeta.resolve(id, parent);
|
||||
} catch (error) {
|
||||
if (opts?.try) {
|
||||
return undefined;
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jiti.import = async function (id, opts) {
|
||||
for (const suffix of ["", "/index"]) {
|
||||
// prettier-ignore
|
||||
for (const ext of ["", ".js", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts"]) {
|
||||
try {
|
||||
const resolved = this.esmResolve(id + suffix + ext, opts);
|
||||
if (!resolved) {
|
||||
continue;
|
||||
}
|
||||
let importAttrs = undefined
|
||||
if (resolved.endsWith('.json')) {
|
||||
importAttrs = { with: { type: 'json'}}
|
||||
}
|
||||
return await import(resolved, importAttrs);
|
||||
} catch (error) {
|
||||
if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'ERR_UNSUPPORTED_DIR_IMPORT') {
|
||||
continue
|
||||
}
|
||||
if (opts?.try) {
|
||||
return undefined;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!opts?.try) {
|
||||
const parent = normalizeParentURL(opts?.parentURL || parentURL);
|
||||
const error = new Error(
|
||||
`[jiti] [ERR_MODULE_NOT_FOUND] Cannot import '${id}' from '${parent}'.`,
|
||||
);
|
||||
error.code = "ERR_MODULE_NOT_FOUND";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
jiti.transform = () => {
|
||||
throw unsupportedError(
|
||||
"`jiti.transform()` is not supported in native mode.",
|
||||
);
|
||||
};
|
||||
|
||||
jiti.evalModule = () => {
|
||||
throw unsupportedError(
|
||||
"`jiti.evalModule()` is not supported in native mode.",
|
||||
);
|
||||
};
|
||||
|
||||
jiti.main = undefined;
|
||||
jiti.extensions = Object.create(null);
|
||||
jiti.cache = Object.create(null);
|
||||
|
||||
return jiti;
|
||||
}
|
||||
|
||||
export default createJiti;
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
*/
|
||||
function unsupportedError(message) {
|
||||
throw new Error(
|
||||
`[jiti] ${message} (import or require 'jiti' instead of 'jiti/native' for more features).`,
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeParentURL(input) {
|
||||
if (!input) {
|
||||
return "file:///";
|
||||
}
|
||||
if (typeof filename !== "string" || input.startsWith("file://")) {
|
||||
return input;
|
||||
}
|
||||
if (input.endsWith("/")) {
|
||||
input += "_"; // append a dummy filename
|
||||
}
|
||||
return `file://${input}`;
|
||||
}
|
1
new_site/node_modules/jiti/lib/jiti-register.d.mts
generated
vendored
Normal file
1
new_site/node_modules/jiti/lib/jiti-register.d.mts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
// eslint-disable-next-line unicorn/no-empty-file
|
4
new_site/node_modules/jiti/lib/jiti-register.mjs
generated
vendored
Normal file
4
new_site/node_modules/jiti/lib/jiti-register.mjs
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// https://nodejs.org/api/module.html#moduleregisterspecifier-parenturl-options
|
||||
import { register } from "node:module";
|
||||
|
||||
register("./jiti-hooks.mjs", import.meta.url, {});
|
23
new_site/node_modules/jiti/lib/jiti.cjs
generated
vendored
Normal file
23
new_site/node_modules/jiti/lib/jiti.cjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
const { createRequire } = require("node:module");
|
||||
const _createJiti = require("../dist/jiti.cjs");
|
||||
const transform = require("../dist/babel.cjs");
|
||||
|
||||
function onError(err) {
|
||||
throw err; /* ↓ Check stack trace ↓ */
|
||||
}
|
||||
|
||||
const nativeImport = (id) => import(id);
|
||||
|
||||
function createJiti(id, opts = {}) {
|
||||
if (!opts.transform) {
|
||||
opts = { ...opts, transform };
|
||||
}
|
||||
return _createJiti(id, opts, {
|
||||
onError,
|
||||
nativeImport,
|
||||
createRequire,
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createJiti;
|
||||
module.exports.createJiti = createJiti;
|
8
new_site/node_modules/jiti/lib/jiti.d.cts
generated
vendored
Normal file
8
new_site/node_modules/jiti/lib/jiti.d.cts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as types from "./types.js";
|
||||
declare const allExports: typeof types & {
|
||||
/**
|
||||
* @deprecated Please use `const { createJiti } = require("jiti")` or use ESM import.
|
||||
*/
|
||||
(...args: Parameters<typeof types.createJiti>): types.Jiti;
|
||||
};
|
||||
export = allExports;
|
8
new_site/node_modules/jiti/lib/jiti.d.mts
generated
vendored
Normal file
8
new_site/node_modules/jiti/lib/jiti.d.mts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createJiti } from "./types.js";
|
||||
|
||||
export * from "./types.js";
|
||||
|
||||
/**
|
||||
* @deprecated Please use `import { createJiti } from "jiti"`
|
||||
*/
|
||||
export default createJiti;
|
22
new_site/node_modules/jiti/lib/jiti.mjs
generated
vendored
Normal file
22
new_site/node_modules/jiti/lib/jiti.mjs
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createRequire } from "node:module";
|
||||
import _createJiti from "../dist/jiti.cjs";
|
||||
import transform from "../dist/babel.cjs";
|
||||
|
||||
function onError(err) {
|
||||
throw err; /* ↓ Check stack trace ↓ */
|
||||
}
|
||||
|
||||
const nativeImport = (id) => import(id);
|
||||
|
||||
export function createJiti(id, opts = {}) {
|
||||
if (!opts.transform) {
|
||||
opts = { ...opts, transform };
|
||||
}
|
||||
return _createJiti(id, opts, {
|
||||
onError,
|
||||
nativeImport,
|
||||
createRequire,
|
||||
});
|
||||
}
|
||||
|
||||
export default createJiti;
|
260
new_site/node_modules/jiti/lib/types.d.ts
generated
vendored
Normal file
260
new_site/node_modules/jiti/lib/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
export declare function createJiti(id: string, userOptions?: JitiOptions): Jiti;
|
||||
|
||||
/**
|
||||
* Jiti instance
|
||||
*
|
||||
* Calling jiti() is similar to CommonJS require() but adds extra features such as Typescript and ESM compatibility.
|
||||
*
|
||||
* **Note:**It is recommended to use `await jiti.import` instead
|
||||
*/
|
||||
export interface Jiti extends NodeRequire {
|
||||
/**
|
||||
* Resolved options
|
||||
*/
|
||||
options: JitiOptions;
|
||||
|
||||
/**
|
||||
* ESM import a module with additional Typescript and ESM compatibility.
|
||||
*
|
||||
* If you need the default export of module, you can use `jiti.import(id, { default: true })` as shortcut to `mod?.default ?? mod`.
|
||||
*/
|
||||
import<T = unknown>(
|
||||
id: string,
|
||||
opts?: JitiResolveOptions & { default?: true },
|
||||
): Promise<T>;
|
||||
|
||||
/**
|
||||
* Resolve with ESM import conditions.
|
||||
*/
|
||||
esmResolve(id: string, parentURL?: string): string;
|
||||
esmResolve<T extends JitiResolveOptions = JitiResolveOptions>(
|
||||
id: string,
|
||||
opts?: T,
|
||||
): T["try"] extends true ? string | undefined : string;
|
||||
|
||||
/**
|
||||
* Transform source code
|
||||
*/
|
||||
transform: (opts: TransformOptions) => string;
|
||||
|
||||
/**
|
||||
* Evaluate transformed code as a module
|
||||
*/
|
||||
evalModule: (source: string, options?: EvalModuleOptions) => unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jiti instance options
|
||||
*/
|
||||
export interface JitiOptions {
|
||||
/**
|
||||
* Filesystem source cache (enabled by default)
|
||||
*
|
||||
* An string can be passed to set the custom cache directory.
|
||||
*
|
||||
* By default (when is `true`), jiti uses `node_modules/.cache/jiti` (if exists) or `{TMP_DIR}/jiti`.
|
||||
*
|
||||
* This option can also be disabled using `JITI_FS_CACHE=false` environment variable.
|
||||
*
|
||||
* **Note:** It is recommended to keep this option enabled for better performance.
|
||||
*/
|
||||
fsCache?: boolean | string;
|
||||
|
||||
/** @deprecated Use `fsCache` option. */
|
||||
cache?: boolean | string;
|
||||
|
||||
/**
|
||||
* Runtime module cache (enabled by default)
|
||||
*
|
||||
* Disabling allows editing code and importing same module multiple times.
|
||||
*
|
||||
* When enabled, jiti integrates with Node.js native CommonJS cache store.
|
||||
*
|
||||
* This option can also be disabled using `JITI_MODULE_CACHE=false` environment variable.
|
||||
*/
|
||||
moduleCache?: boolean;
|
||||
|
||||
/** @deprecated Use `moduleCache` option. */
|
||||
requireCache?: boolean;
|
||||
|
||||
/**
|
||||
* Custom transform function
|
||||
*/
|
||||
transform?: (opts: TransformOptions) => TransformResult;
|
||||
|
||||
/**
|
||||
* Enable verbose debugging (disabled by default).
|
||||
*
|
||||
* Can also be enabled using `JITI_DEBUG=1` environment variable.
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* Enable sourcemaps (enabled by default)
|
||||
*
|
||||
* Can also be disabled using `JITI_SOURCE_MAPS=0` environment variable.
|
||||
*/
|
||||
sourceMaps?: boolean;
|
||||
|
||||
/**
|
||||
* Jiti combines module exports with the `default` export using an internal Proxy to improve compatibility with mixed CJS/ESM usage. You can check the current implementation [here](https://github.com/unjs/jiti/blob/main/src/utils.ts#L105).
|
||||
*
|
||||
* Can be disabled using `JITI_INTEROP_DEFAULT=0` environment variable.
|
||||
*/
|
||||
interopDefault?: boolean;
|
||||
|
||||
/**
|
||||
* Jiti hard source cache version (internal)
|
||||
*/
|
||||
cacheVersion?: string;
|
||||
|
||||
/**
|
||||
* Supported extensions to resolve.
|
||||
*
|
||||
* Default `[".js", ".mjs", ".cjs", ".ts", ".mts", ".cts", ".json"]`
|
||||
*/
|
||||
extensions?: string[];
|
||||
|
||||
/**
|
||||
* Transform options
|
||||
*/
|
||||
transformOptions?: Omit<TransformOptions, "source">;
|
||||
|
||||
/**
|
||||
* Resolve aliases
|
||||
*
|
||||
* You can use `JITI_ALIAS` environment variable to set aliases as a JSON string.
|
||||
*/
|
||||
alias?: Record<string, string>;
|
||||
|
||||
/**
|
||||
* List of modules (within `node_modules`) to always use native require/import for them.
|
||||
*
|
||||
* You can use `JITI_NATIVE_MODULES` environment variable to set native modules as a JSON string.
|
||||
*
|
||||
*/
|
||||
nativeModules?: string[];
|
||||
|
||||
/**
|
||||
* List of modules (within `node_modules`) to transform them regardless of syntax.
|
||||
*
|
||||
* You can use `JITI_TRANSFORM_MODULES` environment variable to set transform modules as a JSON string.
|
||||
*/
|
||||
transformModules?: string[];
|
||||
|
||||
/**
|
||||
* Parent module's import.meta context to use for ESM resolution.
|
||||
*
|
||||
* (Only used for `jiti/native` import)
|
||||
*/
|
||||
importMeta?: ImportMeta;
|
||||
|
||||
/**
|
||||
* Try to use native require and import without jiti transformations first.
|
||||
*
|
||||
* Enabled if Bun is detected.
|
||||
*/
|
||||
tryNative?: boolean;
|
||||
|
||||
/**
|
||||
* Enable JSX support Enable JSX support using [`@babel/plugin-transform-react-jsx`](https://babeljs.io/docs/babel-plugin-transform-react-jsx).
|
||||
*
|
||||
* @default false
|
||||
*
|
||||
* You can also use `JITI_JSX=1` environment variable to enable JSX support.
|
||||
*/
|
||||
jsx?: boolean | JSXOptions;
|
||||
}
|
||||
|
||||
interface NodeRequire {
|
||||
/**
|
||||
* Module cache
|
||||
*/
|
||||
cache: ModuleCache;
|
||||
|
||||
/** @deprecated Prefer `await jiti.import()` for better compatibility. */
|
||||
(id: string): any;
|
||||
|
||||
/** @deprecated Prefer `jiti.esmResolve` for better compatibility. */
|
||||
resolve: {
|
||||
/** @deprecated */
|
||||
(id: string, options?: { paths?: string[] | undefined }): string;
|
||||
/** @deprecated */
|
||||
paths(request: string): string[] | null;
|
||||
};
|
||||
|
||||
/** @deprecated CommonJS API */
|
||||
extensions: Record<
|
||||
".js" | ".json" | ".node",
|
||||
(m: NodeModule, filename: string) => any | undefined
|
||||
>;
|
||||
|
||||
/** @deprecated CommonJS API */
|
||||
main: NodeModule | undefined;
|
||||
}
|
||||
|
||||
export interface NodeModule {
|
||||
/**
|
||||
* `true` if the module is running during the Node.js preload
|
||||
*/
|
||||
isPreloading: boolean;
|
||||
exports: any;
|
||||
require: NodeRequire;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
/** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
|
||||
parent: NodeModule | null | undefined;
|
||||
children: NodeModule[];
|
||||
/**
|
||||
* @since v11.14.0
|
||||
*
|
||||
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
|
||||
*/
|
||||
path: string;
|
||||
paths: string[];
|
||||
}
|
||||
|
||||
export type ModuleCache = Record<string, NodeModule>;
|
||||
|
||||
export type EvalModuleOptions = Partial<{
|
||||
id: string;
|
||||
filename: string;
|
||||
ext: string;
|
||||
cache: ModuleCache;
|
||||
async: boolean;
|
||||
forceTranspile: boolean;
|
||||
}>;
|
||||
|
||||
export interface TransformOptions {
|
||||
source: string;
|
||||
filename?: string;
|
||||
ts?: boolean;
|
||||
retainLines?: boolean;
|
||||
interopDefault?: boolean;
|
||||
async?: boolean;
|
||||
jsx?: boolean | JSXOptions;
|
||||
babel?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface TransformResult {
|
||||
code: string;
|
||||
error?: any;
|
||||
}
|
||||
|
||||
export interface JitiResolveOptions {
|
||||
conditions?: string[];
|
||||
parentURL?: string | URL;
|
||||
try?: boolean;
|
||||
}
|
||||
|
||||
/** Reference: https://babeljs.io/docs/babel-plugin-transform-react-jsx#options */
|
||||
export interface JSXOptions {
|
||||
throwIfNamespace?: boolean;
|
||||
runtime?: "classic" | "automatic";
|
||||
importSource?: string;
|
||||
pragma?: string;
|
||||
pragmaFrag?: string;
|
||||
useBuiltIns?: boolean;
|
||||
useSpread?: boolean;
|
||||
}
|
Reference in New Issue
Block a user