UNPKG

rollup-plugin-import-meta-resolve

Version:
60 lines 2.47 kB
import type { Plugin } from "rollup"; interface ImportMetaResolvePluginOptions { /** * Whether we should strictly follow Node resolution. * * Usually you will have some deviant modules that do use some legacy * resolution algorithm. Since this is generally the case, this is set to * false, but if you can get away with turning this on, then keep it on since * that implies all your modules are compliant with Node resolution! * * @defaultValue `false` */ strict: boolean; /** * Whether we should allow importing JSON files. * * We default to `false` to follow the ESM spec. Once native JSON modules are * supported, this may change. * * @defaultValue `false` */ allowJson: boolean; /** * Whether we should allow importing `.node` files. * * @defaultValue `false` */ allowNode: boolean; } /** * A resolver plugin using the import.meta.resolve algorithm provided by * Node.js. * * This plugin is (more-or-less) a drop-in replacement for the * `@rollup/plugin-node-resolve` plugin. * * There are a few differences between this plugin and the Node.js resolver: * * 1. We allow importing modules without an extension. This is a common * practice in Node.js, but it is not allowed in ESM. We allow it here to * maintain compatibility with a large number of modules. * 2. We allow importing directories. This is not allowed in ESM, but it is * common in Node.js. We allow it here to maintain compatibility with a * large number of modules. * 3. We only allow `import` conditions. This is to ensure that ESM-modules are * consumed first. This doesn't imply that CommonJS modules are not consumed * as `default` conditions and packages without `export` conditions may * still resolve to a CommonJS module. * * You can use `strict` to disable (1) and (2) (which is recommended), but * you may need to fix some modules that are not compliant with the ESM spec. * * This plugin is restrictive by default (e.g. no module roots, no `require` * exports, etc.). This ensures projects are up-to-date and compliant across the * board. If you have custom file tree requirements, it's recommended to use * symlinked directories. */ export default function importMetaResolve(options?: Partial<ImportMetaResolvePluginOptions>): Plugin; export {}; //# sourceMappingURL=rollup-plugin-import-meta-resolve.d.ts.map