main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 5 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[79a0317] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.defineCommonJSHook = defineCommonJSHook;
|
---|
| 7 | exports.makeInvokers = makeInvokers;
|
---|
| 8 | const commonJSHooksKey = "@babel/plugin-transform-modules-commonjs/customWrapperPlugin";
|
---|
| 9 | function defineCommonJSHook(file, hook) {
|
---|
| 10 | let hooks = file.get(commonJSHooksKey);
|
---|
| 11 | if (!hooks) file.set(commonJSHooksKey, hooks = []);
|
---|
| 12 | hooks.push(hook);
|
---|
| 13 | }
|
---|
| 14 | function findMap(arr, cb) {
|
---|
| 15 | if (arr) {
|
---|
| 16 | for (const el of arr) {
|
---|
| 17 | const res = cb(el);
|
---|
| 18 | if (res != null) return res;
|
---|
| 19 | }
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 | function makeInvokers(file) {
|
---|
| 23 | const hooks = file.get(commonJSHooksKey);
|
---|
| 24 | return {
|
---|
| 25 | getWrapperPayload(...args) {
|
---|
| 26 | return findMap(hooks, hook => hook.getWrapperPayload == null ? void 0 : hook.getWrapperPayload(...args));
|
---|
| 27 | },
|
---|
| 28 | wrapReference(...args) {
|
---|
| 29 | return findMap(hooks, hook => hook.wrapReference == null ? void 0 : hook.wrapReference(...args));
|
---|
| 30 | },
|
---|
| 31 | buildRequireWrapper(...args) {
|
---|
| 32 | return findMap(hooks, hook => hook.buildRequireWrapper == null ? void 0 : hook.buildRequireWrapper(...args));
|
---|
| 33 | }
|
---|
| 34 | };
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | //# sourceMappingURL=hooks.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.