![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
relative-cjs
Advanced tools
Calculate relative path for ES Module import, commonJs require function
Install with npm:
npm install relative-cjs
Install with yarn:
yarn add relative-cjs
Very often we need to calculate relative path between two modules to generate CJS require function or ESM import statements.
This is obivious case when you are generating dynamic code or runtime for webpack plugins.
Consider an example where you want to generate CSS stylesheet dynamically with url() function pointing to real files.
Path to require function or import statement must always start with '.' or '..'
This module is extends Jon Schlinkert's relative module and adds '.' or '..' appropriately
var relativeCjs = require('relative-cjs');
relativeCjs('a/b/', 'a');
// ..
relativeCjs('./app', './app');
// ./.
relativeCjs('./a/b.test/', 'a/c'); // b.test being treated as dir, read relative module doc for more info
// ../c
relativeCjs('./a/b.test', 'a/c'); // b.test being treated as file, read relative module doc for more info
// ./c
Please go through relative documentation once. If issue still persists or feature requests, consider opening a new issue
FAQs
Calculate relative path for commonJs require function
We found that relative-cjs 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.