Installations
npm install rollup-plugin-import-map
Score
77.7
Supply Chain
100
Quality
78.1
Maintenance
100
Vulnerability
100
License
Developer
trygve-lie
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
No
Node Version
16.17.1
NPM Version
8.19.2
Statistics
10 Stars
86 Commits
1 Forks
4 Watching
7 Branches
5 Contributors
Updated on 01 Nov 2024
Bundle Size
1.54 kB
Minified
767.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
502,334
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
rollup-plugin-import-map
Rollup plugin to apply import map mapping to ECMAScript modules (ESM) ahead of time.
Installation
1$ npm install rollup-plugin-import-map
Usage
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};
Description
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'
API
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.
Note on the rollup external option
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};
License
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
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
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
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/trygve-lie/rollup-plugin-import-map/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/trygve-lie/rollup-plugin-import-map/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/trygve-lie/rollup-plugin-import-map/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/trygve-lie/rollup-plugin-import-map/publish.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/trygve-lie/rollup-plugin-import-map/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/trygve-lie/rollup-plugin-import-map/test.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:21
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:48
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:20
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 3 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v4.0.0-next.1 not signed: https://api.github.com/repos/trygve-lie/rollup-plugin-import-map/releases/81603742
- Warn: release artifact v4.0.0-next.1 does not have provenance: https://api.github.com/repos/trygve-lie/rollup-plugin-import-map/releases/81603742
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
- Warn: branch protection not enabled for branch 'next'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
3.4
/10
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