bundle-require
- Version 5.1.0
- Published
- 26.4 kB
- 1 dependency
- MIT license
Install
npm i bundle-requireyarn add bundle-requirepnpm add bundle-requireOverview
bundle and require a file
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable dynamicImport
const dynamicImport: RequireFunction;Dynamically import files.
As a temporary workaround for Jest's lack of stable ESM support, we fallback to require if we're in a Jest environment. See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
Parameter file
File path to import.
variable JS_EXT_RE
const JS_EXT_RE: RegExp;Functions
function bundleRequire
bundleRequire: <T = any>( options: Options) => Promise<{ mod: T; dependencies: string[] }>;function externalPlugin
externalPlugin: ({ external, notExternal, externalNodeModules,}?: { external?: (string | RegExp)[] | undefined; notExternal?: (string | RegExp)[] | undefined; externalNodeModules?: boolean | undefined;}) => Plugin;An esbuild plugin to mark node_modules as external
function injectFileScopePlugin
injectFileScopePlugin: ({ readFile,}?: { readFile?: ReadFile | undefined;}) => Plugin;function match
match: (id: string, patterns?: (string | RegExp)[]) => boolean;function tsconfigPathsToRegExp
tsconfigPathsToRegExp: (paths: Record<string, any>) => RegExp[];Interfaces
interface Options
interface Options {}property cwd
cwd?: string;property esbuildOptions
esbuildOptions?: BuildOptions & { /** * @deprecated `esbuildOptions.watch` is deprecated, use `onRebuild` instead */ watch?: | boolean | { onRebuild?: RebuildCallback; };};esbuild options
property external
external?: (string | RegExp)[];External packages
property externalNodeModules
externalNodeModules?: boolean;Automatically mark node_modules as external true -
falsewhenfilepathis in node_modules
property filepath
filepath: string;The filepath to bundle and require
property format
format?: 'cjs' | 'esm';Provide bundle format explicitly to skip the default format inference
property getOutputFile
getOutputFile?: GetOutputFile;Get the path to the output file By default we simply replace the extension with
.bundled_{randomId}.js
property notExternal
notExternal?: (string | RegExp)[];Not external packages
property onRebuild
onRebuild?: (ctx: { err?: Pick<BuildFailure, 'errors' | 'warnings'>; mod?: any; dependencies?: string[];}) => void;Enable watching and call the callback after each rebuild
property preserveTemporaryFile
preserveTemporaryFile?: boolean;Preserve compiled temporary file for debugging Default to
process.env.BUNDLE_REQUIRE_PRESERVE
property readFile
readFile?: ReadFile;property require
require?: RequireFunction;The
requirefunction that is used to load the output file Default to the globalrequirefunction This function can be asynchronous, i.e. returns a Promise
property tsconfig
tsconfig?: string | TsconfigRaw | false;A custom tsconfig path to read
pathsoptionSet to
falseto disable tsconfig Or provide aTsconfigRawobject
Type Aliases
type GetOutputFile
type GetOutputFile = (filepath: string, format: 'esm' | 'cjs') => string;type ReadFile
type ReadFile = (filepath: string) => string;type RebuildCallback
type RebuildCallback = ( error: Pick<BuildFailure, 'errors' | 'warnings'> | null, result: BuildResult | null) => void;type RequireFunction
type RequireFunction = ( outfile: string, ctx: { format: 'cjs' | 'esm'; }) => any;Package Files (1)
Dependencies (1)
Dev Dependencies (7)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/bundle-require.
- Markdown[](https://www.jsdocs.io/package/bundle-require)
- HTML<a href="https://www.jsdocs.io/package/bundle-require"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3051 ms. - Missing or incorrect documentation? Open an issue for this package.
