Gathering detailed insights and metrics for rollup-plugin-external-globals
Gathering detailed insights and metrics for rollup-plugin-external-globals
Gathering detailed insights and metrics for rollup-plugin-external-globals
Gathering detailed insights and metrics for rollup-plugin-external-globals
npm install rollup-plugin-external-globals
Typescript
Module System
Node Version
NPM Version
52.4
Supply Chain
98.5
Quality
83.9
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
3,694,515
Last Day
1,518
Last Week
20,138
Last Month
123,075
Last Year
1,317,165
108 Stars
82 Commits
22 Forks
3 Watching
1 Branches
8 Contributors
Latest Version
0.13.0
Package Id
rollup-plugin-external-globals@0.13.0
Unpacked Size
17.41 kB
Size
5.88 kB
File Count
6
NPM Version
10.9.0
Node Version
22.9.0
Publised On
20 Nov 2024
Cumulative downloads
Total Downloads
Last day
-72.6%
1,518
Compared to previous day
Last week
-33.4%
20,138
Compared to previous week
Last month
-9.9%
123,075
Compared to previous month
Last year
10.9%
1,317,165
Compared to previous year
1
Transform external imports into global variables like Rollup's output.globals
option. See rollup/rollup#2374
npm install -D rollup-plugin-external-globals
1import externalGlobals from "rollup-plugin-external-globals"; 2 3export default { 4 input: ["entry.js"], 5 output: { 6 dir: "dist", 7 format: "es" 8 }, 9 plugins: [ 10 externalGlobals({ 11 jquery: "$" 12 }) 13 ] 14};
The above config transforms
1import jq from "jquery"; 2 3console.log(jq(".test"));
into
1console.log($(".test"));
It also transforms dynamic import:
1import("jquery") 2 .then($ => { 3 $ = $.default || $; 4 console.log($(".test")); 5 }); 6 7// transformed 8Promise.resolve($) 9 .then($ => { 10 $ = $.default || $; 11 console.log($(".test")); 12 });
Note: when using dynamic import, you should notice that in ES module, the resolved object is aways a module namespace, but the global variable might be not.
Note: this plugin only works with import/export syntax. If you are using a module loader transformer e.g.
rollup-plugin-commonjs
, you have to put this plugin after the transformer plugin.
This module exports a single function.
1const plugin = createPlugin( 2 globals: Object | Function, 3 { 4 include?: ReadonlyArray<string | RegExp> | string | RegExp | null, 5 exclude?: ReadonlyArray<string | RegExp> | string | RegExp | null, 6 dynamicWrapper?: Function, 7 constBindings?: Boolean 8 } = {} 9);
globals
is a moduleId
/variableName
map. For example, to map jquery
module to $
:
1const globals = { 2 jquery: "$" 3}
or provide a function that takes the moduleId
and returns the variableName
.
1const globals = (id) => { 2 if (id === "jquery") { 3 return "$"; 4 } 5}
include
is a valid picomatch
glob pattern, or array of patterns. If defined, only matched files would be transformed.
exclude
is a valid picomatch
glob pattern, or array of patterns. Matched files would not be transformed.
dynamicWrapper
is used to specify dynamic imports. Below is the default.
1const dynamicWrapper = (id) => { 2 return `Promise.resolve(${id})`; 3}
Virtual modules are always transformed.
constBindings
is a boolean. If true, the plugin will use const
instead of var
to declare the variable. This usually happens when you try to re-export the global variable. Default is false.
0.13.0 (Nov 20, 2024)
0.12.1 (Nov 15, 2024)
0.12.0 (Aug 11, 2024)
var
, add constBindings
option to use const
instead.0.11.0 (Jun 27, 2024)
0.10.0 (Apr 5, 2024)
exports
field in package.json to export typescript declaration.0.9.2 (Jan 21, 2024)
0.9.1 (Nov 19, 2023)
0.9.0 (Oct 28, 2023)
0.8.0 (May 12, 2023)
0.7.2 (mar 9, 2023)
0.7.0 (Nov 21, 2022)
0.6.1 (Oct 21, 2020)
0.6.0 (Aug 14, 2020)
0.5.0 (Dec 8, 2019)
dynamicWrapper
option.globals
can be a function.0.4.0 (Sep 24, 2019)
import("foo")
=> Promise.resolve(FOO)
.0.3.1 (Jun 6, 2019)
0.3.0 (Mar 25, 2019)
0.2.1 (Oct 2, 2018)
0.2.0 (Sep 12, 2018)
transform
hook.0.1.0 (Aug 5, 2018)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
6 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 5
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 5/30 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
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
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-12-23
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