Gathering detailed insights and metrics for rollup-plugin-import-map
Gathering detailed insights and metrics for rollup-plugin-import-map
Gathering detailed insights and metrics for rollup-plugin-import-map
Gathering detailed insights and metrics for rollup-plugin-import-map
npm install rollup-plugin-import-map
77.7
Supply Chain
100
Quality
78.1
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
10 Stars
86 Commits
1 Forks
4 Watching
7 Branches
5 Contributors
Updated on 01 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-36.9%
418
Compared to previous day
Last week
-15.2%
3,192
Compared to previous week
Last month
-11.7%
16,581
Compared to previous month
Last year
52.4%
239,639
Compared to previous year
Rollup plugin to apply import map mapping to ECMAScript modules (ESM) ahead of time.
1$ npm install rollup-plugin-import-map
1import { rollupImportMapPlugin } from "rollup-plugin-import-map"; 2 3export default { 4 input: "source/main.js", 5 plugins: [rollupImportMapPlugin('source/import-map.json')], 6 output: { 7 file: "build.js", 8 format: "esm", 9 }, 10};
This plugin transforms import specifiers in ESM based on mappings defined in one or more import maps. Import maps are an emerging specification yet to be implemented in browsers, however this module can be used to apply import maps ahead of time.
One use case for import maps is to transform ESM bare import statements to an import statement which is an absolute URL to the same module on a CDN.
Lets say we have the following in our ESM when developing locally with node.js:
1import {html, render} from 'lit-html';
Then on build we can apply the following import map:
1{ 2 "imports": { 3 "lit-html": "https://cdn.eik.dev/npm/lit-html/v1/lit-html.js", 4 } 5}
When applied, our output wil be:
1import * as lit from 'https://cdn.eik.dev/npm/lit-html/v1/lit-html.js'
The API of the plugin is fairly simple. The plugin can take a absolute path to a import map or an import map as an object directly. Values can be passed on as a single value or an Array of multple values.
An absolute path to a import map file:
1export default { 2 input: "source/main.js", 3 plugins: [rollupImportMapPlugin('source/import-map.json')], 4 output: { 5 file: "build.js", 6 format: "esm", 7 }, 8};
Absolute paths to multiple import map files:
1export default { 2 input: "source/main.js", 3 plugins: [rollupImportMapPlugin([ 4 'source/import-map-a.json', 5 'source/import-map-b.json', 6 'source/import-map-c.json', 7 ])], 8 output: { 9 file: "build.js", 10 format: "esm", 11 }, 12};
Mix of absolute paths to import map files and import maps provided as an object:
1export default { 2 input: "source/main.js", 3 plugins: [rollupImportMapPlugin([ 4 'source/import-map-a.json', 5 { 6 "imports": { 7 "lit-html": "https://cdn.eik.dev/npm/lit-html/v1/lit-html.js", 8 } 9 }, 10 'source/import-map-b.json', 11 ])], 12 output: { 13 file: "build.js", 14 format: "esm", 15 }, 16};
When an array of import maps is provided and multiple import maps use the same import specifier, the last import specifier in the array will be the one which is applied.
Any mappings defined by any of the means described above must not occur in the Rollup external
option.
If so, this module will throw.
In other words, this will not work:
1export default { 2 input: "source/main.js", 3 external: ["lit-element"], 4 plugins: [ 5 rollupImportMapPlugin({ 6 imports: { 7 'lit-element': 'https://cdn.eik.dev/lit-element/v2' 8 }, 9 }), 10 ], 11 output: { 12 file: "build.js", 13 format: "esm", 14 }, 15};
Copyright (c) 2020 Trygve Lie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
4 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 3
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More