@paciolan/remote-module-loader 3.0.6 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Remote Module Loader 
|
|
2
2
|
|
|
3
|
-
Loads a CommonJS module from a remote URL for the Browser or Node.js.
|
|
3
|
+
Loads a CommonJS, AMD, or UMD module from a remote URL for the Browser or Node.js.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -61,7 +61,7 @@ export default createLoadRemoteModule({ requires });
|
|
|
61
61
|
|
|
62
62
|
The default loader can be overridden if you want to use an alternate method.
|
|
63
63
|
|
|
64
|
-
This example uses `
|
|
64
|
+
This example uses `fetch` for the fetcher.
|
|
65
65
|
|
|
66
66
|
```javascript
|
|
67
67
|
/**
|
|
@@ -69,9 +69,8 @@ This example uses `axios` for the fetcher.
|
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
import createLoadRemoteModule from "@paciolan/remote-module-loader";
|
|
72
|
-
import axios from "axios";
|
|
73
72
|
|
|
74
|
-
const fetcher = url =>
|
|
73
|
+
const fetcher = url => fetch(url).then(response => response.text());
|
|
75
74
|
|
|
76
75
|
export default createLoadRemoteModule({ fetcher });
|
|
77
76
|
```
|
|
@@ -139,9 +138,9 @@ main();
|
|
|
139
138
|
|
|
140
139
|
## Creating a Remote Module
|
|
141
140
|
|
|
142
|
-
Remote
|
|
141
|
+
Remote modules can be in CommonJS, AMD, or UMD format. The loader provides both `require`/`module`/`exports` (CommonJS) and `define` (AMD) to every module, so the module itself determines which format to use.
|
|
143
142
|
|
|
144
|
-
|
|
143
|
+
### CommonJS
|
|
145
144
|
|
|
146
145
|
```javascript
|
|
147
146
|
function helloWorld() {
|
|
@@ -163,11 +162,33 @@ exports = {
|
|
|
163
162
|
exports.default = "SUCCESS!";
|
|
164
163
|
```
|
|
165
164
|
|
|
165
|
+
### AMD
|
|
166
|
+
|
|
167
|
+
```javascript
|
|
168
|
+
define(["exports"], function (exports) {
|
|
169
|
+
exports.default = function helloWorld() {
|
|
170
|
+
console.log("Hello World!");
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
AMD modules can also return a value directly from the factory:
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
define(function () {
|
|
179
|
+
return {
|
|
180
|
+
default: function helloWorld() {
|
|
181
|
+
console.log("Hello World!");
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
166
187
|
### Webpack
|
|
167
188
|
|
|
168
|
-
Webpack can be setup to export as CommonJS.
|
|
189
|
+
Webpack can be setup to export as CommonJS or AMD.
|
|
169
190
|
|
|
170
|
-
Inside `webpack.config.js`, set the `libraryTarget` to `"commonjs"`.
|
|
191
|
+
Inside `webpack.config.js`, set the `libraryTarget` to `"commonjs"` or `"amd"`.
|
|
171
192
|
|
|
172
193
|
```javascript
|
|
173
194
|
module.exports = {
|
|
@@ -177,6 +198,14 @@ module.exports = {
|
|
|
177
198
|
};
|
|
178
199
|
```
|
|
179
200
|
|
|
201
|
+
```javascript
|
|
202
|
+
module.exports = {
|
|
203
|
+
output: {
|
|
204
|
+
libraryTarget: "amd"
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
```
|
|
208
|
+
|
|
180
209
|
Dependencies should be excluded from the bundle because they will be provided by the Web Application can be added to webpack's `externals` section.
|
|
181
210
|
|
|
182
211
|
This will prevent webpack from bundling duplicate 3rd party libraries, decreasing the bundle size.
|
|
@@ -196,7 +225,7 @@ module.exports = {
|
|
|
196
225
|
|
|
197
226
|
Sites with a `content_security_policy` header set are likely to not work. CSP puts a restriction on using `new Function`, which `remote-module-loader` relies upon.
|
|
198
227
|
|
|
199
|
-
[Read more on CSP](https://developer.
|
|
228
|
+
[Read more on CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)
|
|
200
229
|
|
|
201
230
|
## Alternatives
|
|
202
231
|
|
|
@@ -204,6 +233,6 @@ Sites with a `content_security_policy` header set are likely to not work. CSP pu
|
|
|
204
233
|
|
|
205
234
|
## Contributors
|
|
206
235
|
|
|
207
|
-
Joel Thoms (https://
|
|
236
|
+
Joel Thoms (https://x.com/joelnet)
|
|
208
237
|
|
|
209
238
|
Icon made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](www.flaticon.com)
|
|
@@ -19,8 +19,31 @@ var createLoadRemoteModule = function (_a) {
|
|
|
19
19
|
return _fetcher(url).then(function (data) {
|
|
20
20
|
var exports = {};
|
|
21
21
|
var module = { exports: exports };
|
|
22
|
-
var
|
|
23
|
-
|
|
22
|
+
var define = function () {
|
|
23
|
+
var args = [];
|
|
24
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25
|
+
args[_i] = arguments[_i];
|
|
26
|
+
}
|
|
27
|
+
var factory;
|
|
28
|
+
var deps;
|
|
29
|
+
if (typeof args[args.length - 1] === "function") {
|
|
30
|
+
factory = args.pop();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
module.exports = args[args.length - 1];
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
deps = Array.isArray(args[args.length - 1]) ? args.pop() : ["require", "exports", "module"];
|
|
37
|
+
var builtins = { exports: exports, require: _requires, module: module };
|
|
38
|
+
var resolved = deps.map(function (dep) { return builtins[dep] || _requires(dep); });
|
|
39
|
+
var result = factory.apply(void 0, resolved);
|
|
40
|
+
if (result !== undefined) {
|
|
41
|
+
module.exports = result;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
define.amd = {};
|
|
45
|
+
var func = new Function("require", "module", "exports", "define", data);
|
|
46
|
+
func(_requires, module, exports, define);
|
|
24
47
|
return module.exports;
|
|
25
48
|
});
|
|
26
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRemoteModule.js","sourceRoot":"","sources":["../../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,GAAG,IAAI,OAAA,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,EAA/B,CAA+B,CAAC,CAAC;gBAElE,IAAM,MAAM,GAAG,OAAO,eAAI,QAAQ,CAAC,CAAC;gBACpC,IAAI,MAAM,KAAK,SAAS,EAAE;oBACxB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;iBACzB;YACH,CAAC,CAAC;YACF,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;YAEhB,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC1E,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YACzC,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC;IA9BF,CA8BE,CACH,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,sBAAsB,0BAwCjC"}
|
package/gl-sast-report.json
CHANGED
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"version": "1.145.0"
|
|
20
20
|
},
|
|
21
21
|
"type": "sast",
|
|
22
|
-
"start_time": "2026-
|
|
23
|
-
"end_time": "2026-
|
|
22
|
+
"start_time": "2026-04-03T01:47:01",
|
|
23
|
+
"end_time": "2026-04-03T01:47:23",
|
|
24
24
|
"status": "success",
|
|
25
25
|
"observability": {
|
|
26
26
|
"events": [
|
|
27
27
|
{
|
|
28
28
|
"event": "collect_sast_scan_metrics_from_pipeline",
|
|
29
|
-
"property": "
|
|
29
|
+
"property": "10019756-9f77-4683-b535-f031aba4f200",
|
|
30
30
|
"label": "semgrep",
|
|
31
31
|
"value": 0,
|
|
32
32
|
"version": "6.14.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"override_count": 0,
|
|
35
35
|
"passthrough_count": 4,
|
|
36
36
|
"custom_exclude_path_count": 0,
|
|
37
|
-
"time_s":
|
|
37
|
+
"time_s": 22,
|
|
38
38
|
"file_count": 20
|
|
39
39
|
}
|
|
40
40
|
]
|
package/gl-sbom-npm-npm.cdx.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bomFormat": "CycloneDX",
|
|
3
3
|
"specVersion": "1.4",
|
|
4
|
-
"serialNumber": "urn:uuid:
|
|
4
|
+
"serialNumber": "urn:uuid:9c363910-3428-4c0e-864f-603e1c17cc73",
|
|
5
5
|
"version": 1,
|
|
6
6
|
"metadata": {
|
|
7
|
-
"timestamp": "2026-
|
|
7
|
+
"timestamp": "2026-04-03T01:47:02Z",
|
|
8
8
|
"tools": [
|
|
9
9
|
{
|
|
10
10
|
"vendor": "GitLab",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"vendor": {
|
|
8
8
|
"name": "GitLab"
|
|
9
9
|
},
|
|
10
|
-
"version": "7.
|
|
10
|
+
"version": "7.27.0"
|
|
11
11
|
},
|
|
12
12
|
"scanner": {
|
|
13
13
|
"id": "gitleaks",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"version": "8.30.0"
|
|
20
20
|
},
|
|
21
21
|
"type": "secret_detection",
|
|
22
|
-
"start_time": "2026-
|
|
23
|
-
"end_time": "2026-
|
|
22
|
+
"start_time": "2026-04-03T01:47:02",
|
|
23
|
+
"end_time": "2026-04-03T01:47:04",
|
|
24
24
|
"status": "success",
|
|
25
25
|
"observability": {
|
|
26
26
|
"events": [
|
|
27
27
|
{
|
|
28
28
|
"event": "collect_secrets_analyzer_scan_metrics_from_pipeline",
|
|
29
|
-
"time_s":
|
|
29
|
+
"time_s": 1.427022225,
|
|
30
30
|
"exit_code": 0,
|
|
31
31
|
"git_strategy": "FetchNone",
|
|
32
32
|
"repo_size_kb": 667,
|
|
33
|
-
"bytes_scanned":
|
|
33
|
+
"bytes_scanned": 42014
|
|
34
34
|
}
|
|
35
35
|
]
|
|
36
36
|
}
|