UNPKG

vite

Version:

Native-ESM powered web dev build tool

47 lines (46 loc) 1.62 kB
import type { Plugin } from '../plugin'; import type { ResolvedConfig } from '../config'; /** * Server-only plugin that lexes, resolves, rewrites and analyzes url imports. * * - Imports are resolved to ensure they exist on disk * * - Lexes HMR accept calls and updates import relationships in the module graph * * - Bare module imports are resolved (by @rollup-plugin/node-resolve) to * absolute file paths, e.g. * * ```js * import 'foo' * ``` * is rewritten to * ```js * import '/@fs//project/node_modules/foo/dist/foo.js' * ``` * * - CSS imports are appended with `.js` since both the js module and the actual * css (referenced via <link>) may go through the transform pipeline: * * ```js * import './style.css' * ``` * is rewritten to * ```js * import './style.css.js' * ``` */ export declare function importAnalysisPlugin(config: ResolvedConfig): Plugin; /** * Detect import statements to a known optimized CJS dependency and provide * ES named imports interop. We do this by rewriting named imports to a variable * assignment to the corresponding property on the `module.exports` of the cjs * module. Note this doesn't support dynamic re-assignments from within the cjs * module. * * Note that es-module-lexer treats `export * from '...'` as an import as well, * so, we may encounter ExportAllDeclaration here, in which case `undefined` * will be returned. * * Credits \@csr632 via #837 */ export declare function transformCjsImport(importExp: string, url: string, rawUrl: string, importIndex: number): string | undefined;