Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
jest-haste-map
Advanced tools
The jest-haste-map npm package is a utility for building a Haste map, which is a mapping from module names to file paths. It is used by Jest to quickly resolve module dependencies for tests by keeping an in-memory map of all available modules. It can handle duplicate module names and provides a way to query the map for a specific module.
Building a Haste Map
This code sample demonstrates how to create a new HasteMap instance with a configuration object, build the map, and then use it to get the module name for a specific file.
const HasteMap = require('jest-haste-map');
const config = {
// These options are required:
roots: ['/path/to/project'],
extensions: ['js', 'json'],
platforms: ['ios', 'android'],
// You can provide additional options:
computeSha1: true,
// other options...
};
const hasteMap = new HasteMap(config);
hasteMap.build().then(map => {
console.log(map.hasteFS.getModuleName('/path/to/project/file.js'));
});
Querying the Haste Map
This code sample shows how to query the built Haste map for the path of a module given its name, platform, and whether it supports the native platform.
hasteMap.build().then(map => {
const modulePath = map.moduleMap.getModule('moduleName', 'platform', 'supportsNativePlatform');
console.log(modulePath);
});
Metro is a JavaScript bundler for React Native applications. It includes a Haste map implementation similar to jest-haste-map, but it is tailored specifically for React Native and includes additional features for bundling and transforming code.
Webpack is a powerful module bundler for JavaScript applications. While it does not use a Haste map, it provides a similar functionality through its own resolution mechanism, which can handle complex dependency graphs and offers a wide range of plugins for different tasks.
Browserify is a tool for bundling JavaScript files for usage in the browser. Like webpack, it does not use a Haste map, but it allows developers to require modules in the browser by bundling up all dependencies. It's simpler than webpack and may be more suitable for smaller projects.
28.1.3
[jest-leak-detector]
Use native FinalizationRegistry
when it exists to get rid of external C dependency (#12973)[jest-changed-files]
Fix a lock-up after repeated invocations (#12757)[@jest/expect-utils]
Fix deep equality of ImmutableJS OrderedSets (#12977)[jest-mock]
Add index signature support for spyOn
types (#13013, #13020)[jest-snapshot]
Fix indentation of awaited inline snapshots (#12986)FAQs
Unknown package
The npm package jest-haste-map receives a total of 30,485,681 weekly downloads. As such, jest-haste-map popularity was classified as popular.
We found that jest-haste-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.