Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
rollup-plugin-hypothetical
Advanced tools
gives Rollup an imaginary file system, e.g. for testing other plugins
This allows Rollup modules to import hypothetical files passed in as options to the plugin.
npm install --save-dev rollup-plugin-hypothetical
// rollup.config.js
import hypothetical from 'rollup-plugin-hypothetical';
export default {
entry: './dir/a.js',
plugins: [hypothetical({
files: {
'./dir/a.js': `
import foo from './b.js';
foo();
`,
'./dir/b.js': `
import message from 'external';
export default function foo() {
console.log(message);
}
`,
'external/': `
export default "Hello, World!";
`
}
})]
};
To attach a sourcemap to a hypothetical file, simply pass in a { code, map }
object instead of a string. The sourcemap can have its own sources
, sourcesContent
, etc.
An object whose keys are paths, either relative to the current working directory or absolute, and whose values are the code within the hypothetical files at those paths.
Rather than supplying a plain object to options.files
, you may choose to supply a Map
to options.filesMap
. This will allow you to do things like naming your hypothetical files __proto__
.
Defaults to false
. Set this to true
to allow non-external imports to fall through. That way they can be handled either by Rollup's default behavior (reading from the filesystem) or by a plugin further down the chain if there is one.
Defaults to true
. Set this to false
to forbid external imports from falling through.
Defaults to false
. Set this to true
to allow relative imports from supplied external modules to fall through. For instance, suppose you have the following options.files
:
{
'./main.js': `
import 'external/x.js';
`,
'external/x.js': `
import './y.js';
`
}
The supplied file external/x.js
imports external/y.js
, but external/y.js
isn't supplied. This sort of thing is probably a mistake. If it isn't, set options.allowRelativeExternalFallthrough
to true
and remember to include external: ['external/y.js']
in the options you pass to rollup.rollup
. If you forget that part, your build won't work, and weird things may happen instead!
When this is set to true
, the IDs in import
statements won't be treated as paths and will instead be looked up directly in the files
object. There will be no relative importing, path normalization, or restrictions on the contents of IDs.
Set this to an array of file extensions to try appending to imports if an exact match isn't found. Defaults to ['.js', '/']
. If this is set to false
or an empty array, file extensions and trailing slashes in imports will be treated as mandatory.
When this is set to a directory name, relative file paths will be resolved relative to that directory rather than process.cwd()
. When it's set to false
, they will be resolved relative to an imaginary directory that cannot be expressed as an absolute path.
MIT
FAQs
gives Rollup an imaginary file system, e.g. for testing other plugins
The npm package rollup-plugin-hypothetical receives a total of 13,199 weekly downloads. As such, rollup-plugin-hypothetical popularity was classified as popular.
We found that rollup-plugin-hypothetical demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.