@ms-cloudpack/esm-stub-utilities 0.0.2
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/CHANGELOG.json +20 -0
- package/CHANGELOG.md +13 -0
- package/README.md +45 -0
- package/lib/createESMStub.d.ts +8 -0
- package/lib/createESMStub.js +69 -0
- package/lib/createESMStub.js.map +1 -0
- package/lib/createESMStub.test.d.ts +1 -0
- package/lib/createESMStub.test.js +192 -0
- package/lib/createESMStub.test.js.map +1 -0
- package/lib/forbiddenExportNames.d.ts +5 -0
- package/lib/forbiddenExportNames.js +70 -0
- package/lib/forbiddenExportNames.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/initializeBrowserEnvironment.d.ts +4 -0
- package/lib/initializeBrowserEnvironment.js +47 -0
- package/lib/initializeBrowserEnvironment.js.map +1 -0
- package/lib/tryRequire.cjs +12 -0
- package/lib/tryRequire.cjs.map +1 -0
- package/lib/tryRequire.d.cts +2 -0
- package/lib/tryRequire.test.d.ts +1 -0
- package/lib/tryRequire.test.js +15 -0
- package/lib/tryRequire.test.js.map +1 -0
- package/lib/writeESMStub.d.ts +4 -0
- package/lib/writeESMStub.js +16 -0
- package/lib/writeESMStub.js.map +1 -0
- package/package.json +48 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ms-cloudpack/esm-stub-utilities",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Fri, 27 May 2022 20:32:33 GMT",
|
|
6
|
+
"tag": "@ms-cloudpack/esm-stub-utilities_v0.0.2",
|
|
7
|
+
"version": "0.0.2",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "dzearing@microsoft.com",
|
|
12
|
+
"package": "@ms-cloudpack/esm-stub-utilities",
|
|
13
|
+
"commit": "0cc8ffacb753e45c6fa31b462ea8b90da5b185e5",
|
|
14
|
+
"comment": "Initial publish of esm-stub-utilities package."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Change Log - @ms-cloudpack/esm-stub-utilities
|
|
2
|
+
|
|
3
|
+
This log was last generated on Fri, 27 May 2022 20:32:33 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 0.0.2
|
|
8
|
+
|
|
9
|
+
Fri, 27 May 2022 20:32:33 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Initial publish of esm-stub-utilities package. (dzearing@microsoft.com)
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @ms-cloudpack/esm-stub-utilities
|
|
2
|
+
|
|
3
|
+
This library contains utilities for generating ESM stubs for CommonJS modules. Some bundlers require this for extracting named exports needed to produce a browser-compatible ESM bundle.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Generate a stub given a JavaScript entry path:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { createESMStub } from '@ms-cloudpack/esm-stub-utilities';
|
|
11
|
+
|
|
12
|
+
const esmStub = await createESMStub('/path/to/entry.js', '/path/to/stub.js');
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This return an esm stub string, based on loading the package in node and parsing exported keys. Example output:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import content from '/path/to/entry.js';
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
default: content,
|
|
22
|
+
named1: content.named1,
|
|
23
|
+
named2: content.named2
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Writes the path to the stub to a file:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { writeESMStub } from '@ms-cloudpack/esm-stub-utilities';
|
|
31
|
+
|
|
32
|
+
await writeESMStub('./path/to/entry.js', './path/to/stub.js');
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Special considerations
|
|
36
|
+
|
|
37
|
+
When evaluating named entries in the `exports` of the cjs file, the library is loaded in the node process. A few libraries are used to simulate the browser environment in order for the script to load. (E.g. some libraries will reference `window` on load, and therefore must be parsed in an environment that accommodates this.)
|
|
38
|
+
|
|
39
|
+
Libraries which export a `default` entry in their `exports` will have that value preserved as the `default` export in the stub. However libraries which have an object exported which don't have a `default` key will have the entire object exported as the default.
|
|
40
|
+
|
|
41
|
+
Libraries which export a function or literal value as the `exports` result will have a default export for that entry.
|
|
42
|
+
|
|
43
|
+
Some libraries don't export anything. In this case, the stub will simply import the entry.
|
|
44
|
+
|
|
45
|
+
Exported members that are keywords will be ignored. (E.g. `module.exports = { 'delete': "foo" };` would be considered an empty export.)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an ESM stub for CommonJS modules.
|
|
3
|
+
* @param entryPath - The full path to the CommonJS entry file.
|
|
4
|
+
* @param stubPath - The path where the stub file will live. This is important for determining
|
|
5
|
+
* relative import paths.
|
|
6
|
+
* @param packageExport - The exported package.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createESMStub(entryPath: string, stubPath: string): string;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { slash } from '@ms-cloudpack/path-utilities';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { initializeBrowserEnvironment } from './initializeBrowserEnvironment.js';
|
|
4
|
+
import { tryRequire } from './tryRequire.cjs';
|
|
5
|
+
import { forbiddenExportNames } from './forbiddenExportNames.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generates an ESM stub for CommonJS modules.
|
|
8
|
+
* @param entryPath - The full path to the CommonJS entry file.
|
|
9
|
+
* @param stubPath - The path where the stub file will live. This is important for determining
|
|
10
|
+
* relative import paths.
|
|
11
|
+
* @param packageExport - The exported package.
|
|
12
|
+
*/
|
|
13
|
+
export function createESMStub(entryPath, stubPath) {
|
|
14
|
+
const result = [];
|
|
15
|
+
const relativePath = './' + slash(path.relative(path.dirname(stubPath), entryPath));
|
|
16
|
+
// Try and require the entry file.
|
|
17
|
+
initializeBrowserEnvironment();
|
|
18
|
+
const packageExport = tryRequire(entryPath);
|
|
19
|
+
if (packageExport) {
|
|
20
|
+
let isDefaultExported = false;
|
|
21
|
+
const isExportObject = typeof packageExport === 'object';
|
|
22
|
+
const isExportFunction = typeof packageExport === 'function';
|
|
23
|
+
if (isExportObject || isExportFunction) {
|
|
24
|
+
// Make sure to filter keywords.
|
|
25
|
+
const namedExports = Object.keys(packageExport).filter((name) => forbiddenExportNames.indexOf(name) < 0);
|
|
26
|
+
if (namedExports.length || isExportFunction) {
|
|
27
|
+
result.push(`import packageExport from "${relativePath}";`);
|
|
28
|
+
}
|
|
29
|
+
if (namedExports.length) {
|
|
30
|
+
result.push(`const {`);
|
|
31
|
+
for (const namedExport of namedExports) {
|
|
32
|
+
if (namedExport === 'default') {
|
|
33
|
+
isDefaultExported = true;
|
|
34
|
+
result.push(` default: __moduleDefault,`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result.push(` ${namedExport},`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
result.push(`} = packageExport;`, ``);
|
|
41
|
+
if (isDefaultExported) {
|
|
42
|
+
result.push(`export {`, ...namedExports.filter((n) => n !== 'default').map((n) => `${n},`), `__moduleDefault as default,`, `}`);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
result.push(`export {`, ...namedExports.map((n) => ` ${n},`), ` packageExport as default,`, `}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (isExportObject) {
|
|
49
|
+
// No named exports...
|
|
50
|
+
// Object with no members? Must be a polyfill. Just import it and don't export anything.
|
|
51
|
+
result.push(`import "${relativePath}";`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Must be a function. Export it as default.
|
|
55
|
+
result.push(`export default packageExport;`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// not an object or function
|
|
60
|
+
result.push(`export default packageExport;`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// unable to import the module in node.
|
|
65
|
+
result.push(`import "${relativePath}";`);
|
|
66
|
+
}
|
|
67
|
+
return result.join('\n');
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=createESMStub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createESMStub.js","sourceRoot":"","sources":["../src/createESMStub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,QAAgB;IAC/D,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,YAAY,GAAG,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAEpF,kCAAkC;IAClC,4BAA4B,EAAE,CAAC;IAE/B,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAE5C,IAAI,aAAa,EAAE;QACjB,IAAI,iBAAiB,GAAG,KAAK,CAAC;QAC9B,MAAM,cAAc,GAAG,OAAO,aAAa,KAAK,QAAQ,CAAC;QACzD,MAAM,gBAAg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AC;iBACpG;aACF;iBAAM,IAAI,cAAc,EAAE;gBACzB,sBAAsB;gBACtB,wFAAwF;gBACxF,MAAM,CAAC,IAAI,CAAC,WAAW,YAAY,IAAI,CAAC,CAAC;aAC1C;iBAAM;gBACL,4CAA4C;gBAC5C,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;aAC9C;SACF;aAAM;YACL,4BAA4B;YAC5B,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;SAC9C;KACF;SAAM;QACL,uCAAuC;QACvC,MAAM,CAAC,IAAI,CAAC,WAAW,YAAY,IAAI,CAAC,CAAC;KAC1C;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { createESMStub } from './createESMStub.js';
|
|
4
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const testScenariosPath = path.join(dirname, '../test-scenarios');
|
|
6
|
+
const stubPath = path.join(testScenariosPath, 'esm-stub.js');
|
|
7
|
+
describe('createESMStub', () => {
|
|
8
|
+
it('should create an ESM stub for CommonJS object export without a default', () => {
|
|
9
|
+
expect(createESMStub(path.join(testScenariosPath, 'object-export.cjs'), stubPath)).toMatchInlineSnapshot(`
|
|
10
|
+
"import packageExport from \\"./object-export.cjs\\";
|
|
11
|
+
const {
|
|
12
|
+
a,
|
|
13
|
+
b,
|
|
14
|
+
c,
|
|
15
|
+
d,
|
|
16
|
+
} = packageExport;
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
a,
|
|
20
|
+
b,
|
|
21
|
+
c,
|
|
22
|
+
d,
|
|
23
|
+
packageExport as default,
|
|
24
|
+
}"
|
|
25
|
+
`);
|
|
26
|
+
});
|
|
27
|
+
it('should create an ESM stub for CommonJS object export with a named default', () => {
|
|
28
|
+
expect(createESMStub(path.join(testScenariosPath, 'object-export-with-default.cjs'), stubPath))
|
|
29
|
+
.toMatchInlineSnapshot(`
|
|
30
|
+
"import packageExport from \\"./object-export-with-default.cjs\\";
|
|
31
|
+
const {
|
|
32
|
+
default: __moduleDefault,
|
|
33
|
+
a,
|
|
34
|
+
b,
|
|
35
|
+
c,
|
|
36
|
+
d,
|
|
37
|
+
} = packageExport;
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
a,
|
|
41
|
+
b,
|
|
42
|
+
c,
|
|
43
|
+
d,
|
|
44
|
+
__moduleDefault as default,
|
|
45
|
+
}"
|
|
46
|
+
`);
|
|
47
|
+
});
|
|
48
|
+
it('should create an ESM stub for CommonJS function export', () => {
|
|
49
|
+
expect(createESMStub(path.join(testScenariosPath, 'function-export.cjs'), stubPath)).toMatchInlineSnapshot(`
|
|
50
|
+
"import packageExport from \\"./function-export.cjs\\";
|
|
51
|
+
export default packageExport;"
|
|
52
|
+
`);
|
|
53
|
+
});
|
|
54
|
+
it('should create an ESM stub for CommonJS string export', () => {
|
|
55
|
+
expect(createESMStub(path.join(testScenariosPath, 'string-export.cjs'), stubPath)).toMatchInlineSnapshot(`"export default packageExport;"`);
|
|
56
|
+
});
|
|
57
|
+
it("should throw when the code can't be parsed", () => {
|
|
58
|
+
expect(() => createESMStub(path.join(testScenariosPath, 'throws-error.cjs'), stubPath)).toThrow();
|
|
59
|
+
});
|
|
60
|
+
it('can handle a CommonJS module with no exports', () => {
|
|
61
|
+
expect(createESMStub(path.join(testScenariosPath, 'no-exports.cjs'), stubPath)).toMatchInlineSnapshot(`"import \\"./no-exports.cjs\\";"`);
|
|
62
|
+
});
|
|
63
|
+
it('can snapshot react', () => {
|
|
64
|
+
expect(createESMStub('react', stubPath)).toMatchInlineSnapshot(`
|
|
65
|
+
"import packageExport from \\"./../react\\";
|
|
66
|
+
const {
|
|
67
|
+
Fragment,
|
|
68
|
+
StrictMode,
|
|
69
|
+
Profiler,
|
|
70
|
+
Suspense,
|
|
71
|
+
Children,
|
|
72
|
+
Component,
|
|
73
|
+
PureComponent,
|
|
74
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
75
|
+
cloneElement,
|
|
76
|
+
createContext,
|
|
77
|
+
createElement,
|
|
78
|
+
createFactory,
|
|
79
|
+
createRef,
|
|
80
|
+
forwardRef,
|
|
81
|
+
isValidElement,
|
|
82
|
+
lazy,
|
|
83
|
+
memo,
|
|
84
|
+
useCallback,
|
|
85
|
+
useContext,
|
|
86
|
+
useDebugValue,
|
|
87
|
+
useEffect,
|
|
88
|
+
useImperativeHandle,
|
|
89
|
+
useLayoutEffect,
|
|
90
|
+
useMemo,
|
|
91
|
+
useReducer,
|
|
92
|
+
useRef,
|
|
93
|
+
useState,
|
|
94
|
+
version,
|
|
95
|
+
} = packageExport;
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
Fragment,
|
|
99
|
+
StrictMode,
|
|
100
|
+
Profiler,
|
|
101
|
+
Suspense,
|
|
102
|
+
Children,
|
|
103
|
+
Component,
|
|
104
|
+
PureComponent,
|
|
105
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
106
|
+
cloneElement,
|
|
107
|
+
createContext,
|
|
108
|
+
createElement,
|
|
109
|
+
createFactory,
|
|
110
|
+
createRef,
|
|
111
|
+
forwardRef,
|
|
112
|
+
isValidElement,
|
|
113
|
+
lazy,
|
|
114
|
+
memo,
|
|
115
|
+
useCallback,
|
|
116
|
+
useContext,
|
|
117
|
+
useDebugValue,
|
|
118
|
+
useEffect,
|
|
119
|
+
useImperativeHandle,
|
|
120
|
+
useLayoutEffect,
|
|
121
|
+
useMemo,
|
|
122
|
+
useReducer,
|
|
123
|
+
useRef,
|
|
124
|
+
useState,
|
|
125
|
+
version,
|
|
126
|
+
packageExport as default,
|
|
127
|
+
}"
|
|
128
|
+
`);
|
|
129
|
+
});
|
|
130
|
+
it('can snapshot react-dom', () => {
|
|
131
|
+
expect(createESMStub('react-dom', stubPath)).toMatchInlineSnapshot(`
|
|
132
|
+
"import packageExport from \\"./../react-dom\\";
|
|
133
|
+
const {
|
|
134
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
135
|
+
createPortal,
|
|
136
|
+
findDOMNode,
|
|
137
|
+
flushSync,
|
|
138
|
+
hydrate,
|
|
139
|
+
render,
|
|
140
|
+
unmountComponentAtNode,
|
|
141
|
+
unstable_batchedUpdates,
|
|
142
|
+
unstable_createPortal,
|
|
143
|
+
unstable_renderSubtreeIntoContainer,
|
|
144
|
+
version,
|
|
145
|
+
} = packageExport;
|
|
146
|
+
|
|
147
|
+
export {
|
|
148
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
149
|
+
createPortal,
|
|
150
|
+
findDOMNode,
|
|
151
|
+
flushSync,
|
|
152
|
+
hydrate,
|
|
153
|
+
render,
|
|
154
|
+
unmountComponentAtNode,
|
|
155
|
+
unstable_batchedUpdates,
|
|
156
|
+
unstable_createPortal,
|
|
157
|
+
unstable_renderSubtreeIntoContainer,
|
|
158
|
+
version,
|
|
159
|
+
packageExport as default,
|
|
160
|
+
}"
|
|
161
|
+
`);
|
|
162
|
+
});
|
|
163
|
+
it('can generate a stub for a browser-sensitive CommonJS module', () => {
|
|
164
|
+
expect(createESMStub(path.join(testScenariosPath, 'browser-sensitive.cjs'), stubPath)).toMatchInlineSnapshot(`
|
|
165
|
+
"import packageExport from \\"./browser-sensitive.cjs\\";
|
|
166
|
+
const {
|
|
167
|
+
getDiv,
|
|
168
|
+
} = packageExport;
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
getDiv,
|
|
172
|
+
packageExport as default,
|
|
173
|
+
}"
|
|
174
|
+
`);
|
|
175
|
+
});
|
|
176
|
+
it('can ignore JavaScript keywords in named exports', () => {
|
|
177
|
+
// Should be missing "delete" in the named exports.
|
|
178
|
+
expect(createESMStub(path.join(testScenariosPath, 'export-with-keyword.cjs'), stubPath)).toMatchInlineSnapshot(`
|
|
179
|
+
"import packageExport from \\"./export-with-keyword.cjs\\";
|
|
180
|
+
const {
|
|
181
|
+
default: __moduleDefault,
|
|
182
|
+
a,
|
|
183
|
+
} = packageExport;
|
|
184
|
+
|
|
185
|
+
export {
|
|
186
|
+
a,
|
|
187
|
+
__moduleDefault as default,
|
|
188
|
+
}"
|
|
189
|
+
`);
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
//# sourceMappingURL=createESMStub.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createESMStub.test.js","sourceRoot":"","sources":["../src/createESMStub.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAE7D,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,wEAAwE,EAAE,GAAG,EAAE;QAChF,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;KAgBxG,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACnF,MAAM,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;;;;;;;;;;;;;;;;;;;;;KAgE9D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BlE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACrE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,uBAAuB,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;KAU5G,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,mDAAmD;QACnD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,yBAAyB,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;KAW9G,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists all export names which create problems with esm output. Mostly
|
|
3
|
+
* this includes the JavaScript keywords, minus "default".
|
|
4
|
+
*/
|
|
5
|
+
export const forbiddenExportNames = [
|
|
6
|
+
'abstract',
|
|
7
|
+
'arguments',
|
|
8
|
+
'await',
|
|
9
|
+
'boolean',
|
|
10
|
+
'break',
|
|
11
|
+
'byte',
|
|
12
|
+
'case',
|
|
13
|
+
'catch',
|
|
14
|
+
'char',
|
|
15
|
+
'class',
|
|
16
|
+
'const',
|
|
17
|
+
'continue',
|
|
18
|
+
'debugger',
|
|
19
|
+
'delete',
|
|
20
|
+
'do',
|
|
21
|
+
'double',
|
|
22
|
+
'else',
|
|
23
|
+
'enum',
|
|
24
|
+
'eval',
|
|
25
|
+
'export',
|
|
26
|
+
'extends',
|
|
27
|
+
'false',
|
|
28
|
+
'final',
|
|
29
|
+
'finally',
|
|
30
|
+
'float',
|
|
31
|
+
'for',
|
|
32
|
+
'function',
|
|
33
|
+
'goto',
|
|
34
|
+
'if',
|
|
35
|
+
'implements',
|
|
36
|
+
'import',
|
|
37
|
+
'in',
|
|
38
|
+
'instanceof',
|
|
39
|
+
'int',
|
|
40
|
+
'interface',
|
|
41
|
+
'let',
|
|
42
|
+
'long',
|
|
43
|
+
'native',
|
|
44
|
+
'new',
|
|
45
|
+
'null',
|
|
46
|
+
'package',
|
|
47
|
+
'private',
|
|
48
|
+
'protected',
|
|
49
|
+
'public',
|
|
50
|
+
'return',
|
|
51
|
+
'short',
|
|
52
|
+
'static',
|
|
53
|
+
'super',
|
|
54
|
+
'switch',
|
|
55
|
+
'synchronized',
|
|
56
|
+
'this',
|
|
57
|
+
'throw',
|
|
58
|
+
'throws',
|
|
59
|
+
'transient',
|
|
60
|
+
'true',
|
|
61
|
+
'try',
|
|
62
|
+
'typeof',
|
|
63
|
+
'var',
|
|
64
|
+
'void',
|
|
65
|
+
'volatile',
|
|
66
|
+
'while',
|
|
67
|
+
'with',
|
|
68
|
+
'yield',
|
|
69
|
+
];
|
|
70
|
+
//# sourceMappingURL=forbiddenExportNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forbiddenExportNames.js","sourceRoot":"","sources":["../src/forbiddenExportNames.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,UAAU;IACV,WAAW;IACX,OAAO;IACP,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,OAAO;IACP,KAAK;IACL,UAAU;IACV,MAAM;IACN,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,KAAK;IACL,WAAW;IACX,KAAK;IACL,MAAM;IACN,QAAQ;IACR,KAAK;IACL,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,cAAc;IACd,MAAM;IACN,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;CACR,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initializes a browser environment (e.g. by setting up the global `window` in a node environment.)
|
|
3
|
+
*/
|
|
4
|
+
export async function initializeBrowserEnvironment() {
|
|
5
|
+
if (typeof window === 'undefined' && typeof global !== 'undefined') {
|
|
6
|
+
const { JSDOM } = await import('jsdom');
|
|
7
|
+
const btoa = await import('btoa');
|
|
8
|
+
const atob = await import('atob');
|
|
9
|
+
await import('jsdom-global');
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
await import('regenerator-runtime/runtime');
|
|
13
|
+
const dom = new JSDOM();
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const globalThis = global;
|
|
16
|
+
globalThis.window = dom.window;
|
|
17
|
+
globalThis.window.requestAnimationFrame = dom.window.setTimeout;
|
|
18
|
+
globalThis.window.cancelAnimationFrame = dom.window.clearTimeout;
|
|
19
|
+
globalThis.btoa = btoa;
|
|
20
|
+
globalThis.atob = atob;
|
|
21
|
+
globalThis.self = dom.window;
|
|
22
|
+
globalThis.document = dom.window.document;
|
|
23
|
+
globalThis.navigator = dom.window.navigator;
|
|
24
|
+
// eslint-disable-next-line etc/no-deprecated
|
|
25
|
+
const createElement = dom.window.document.createElement.bind(dom.window.document);
|
|
26
|
+
// Mock out canvas.
|
|
27
|
+
globalThis.document.createElement =
|
|
28
|
+
globalThis.window.createElement =
|
|
29
|
+
globalThis.createElement =
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
(tagName, ...args) => {
|
|
32
|
+
if (tagName === 'canvas') {
|
|
33
|
+
return {
|
|
34
|
+
getContext: () => ({
|
|
35
|
+
fillRect: () => {
|
|
36
|
+
/* no-op */
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
measureText: () => ({}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
return createElement.apply(dom.window.document, [tagName, ...args]);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=initializeBrowserEnvironment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializeBrowserEnvironment.js","sourceRoot":"","sources":["../src/initializeBrowserEnvironment.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAClE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC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G,EAAE,CAAC,CAAC;oCACjB,QAAQ,EAAE,GAAG,EAAE;wCACb,WAAW;oCACb,CAAC;iCACF,CAAC;gCACF,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;6BACxB,CAAC;yBACH;wBAED,8DAA8D;wBAC9D,OAAQ,aAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;oBAC/E,CAAC,CAAC;KACP;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
/**
|
|
4
|
+
* Requires a CommonJS entry file. We need to call require to ensure the cjs module is
|
|
5
|
+
* parsed and we aren't redirected to an esm via exports maps.
|
|
6
|
+
*/
|
|
7
|
+
module.exports = {
|
|
8
|
+
tryRequire(modulePath) {
|
|
9
|
+
return require(modulePath);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=tryRequire.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tryRequire.cjs","sourceRoot":"","sources":["../src/tryRequire.cjs"],"names":[],"mappings":";AAAA,6BAA6B;AAE7B;;;GAGG;AACH,MAAM,CAAC,OAAO,GAAG;IACf,UAAU,CAAC,UAAU;QACnB,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { tryRequire } from './tryRequire.cjs';
|
|
4
|
+
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
const testScenariosPath = path.join(dirname, '../test-scenarios');
|
|
6
|
+
describe('tryRequire', () => {
|
|
7
|
+
it('can successfully require a CommonJS module', () => {
|
|
8
|
+
const module = tryRequire(path.join(testScenariosPath, 'object-export.cjs'));
|
|
9
|
+
expect(module).toBeTruthy();
|
|
10
|
+
});
|
|
11
|
+
it('can throw when the module cannot be required', () => {
|
|
12
|
+
expect(() => tryRequire('this-module-does-not-exist')).toThrow();
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=tryRequire.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tryRequire.test.js","sourceRoot":"","sources":["../src/tryRequire.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AAElE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,CAAC;QAC7E,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { slash } from '@ms-cloudpack/path-utilities';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { createESMStub } from './createESMStub.js';
|
|
4
|
+
const { writeFile } = fs.promises;
|
|
5
|
+
/**
|
|
6
|
+
* Generates an ESM stub for CommonJS modules.
|
|
7
|
+
*/
|
|
8
|
+
export async function writeESMStub(entryPath, stubPath) {
|
|
9
|
+
// Ensure forward slashes
|
|
10
|
+
entryPath = slash(entryPath);
|
|
11
|
+
// If we have a package export, we can generate an ESM stub.
|
|
12
|
+
const esmStub = createESMStub(entryPath, stubPath);
|
|
13
|
+
// Write the stub to disk.
|
|
14
|
+
await writeFile(stubPath, esmStub);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=writeESMStub.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeESMStub.js","sourceRoot":"","sources":["../src/writeESMStub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC;AAClC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,SAAiB,EAAE,QAAgB;IACpE,yBAAyB;IACzB,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAE7B,4DAA4D;IAC5D,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEnD,0BAA0B;IAC1B,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ms-cloudpack/esm-stub-utilities",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Generates ESM stubs for CommonJS entry files.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"import": "./lib/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@ms-cloudpack/path-utilities": "^0.3.0",
|
|
17
|
+
"atob": "^2.1.2",
|
|
18
|
+
"btoa": "^1.2.1",
|
|
19
|
+
"jsdom-global": "^3.0.2",
|
|
20
|
+
"jsdom": "^19.0.0",
|
|
21
|
+
"regenerator-runtime": "^0.13.9"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@ms-cloudpack/eslint-config-base": "*",
|
|
25
|
+
"@ms-cloudpack/scripts": "*",
|
|
26
|
+
"@types/atob": "^2.1.2",
|
|
27
|
+
"@types/btoa": "^1.2.3",
|
|
28
|
+
"@types/jsdom-global": "^3.0.2",
|
|
29
|
+
"@types/jsdom": "^16.2.14",
|
|
30
|
+
"@types/regenerator-runtime": "^0.13.1",
|
|
31
|
+
"react-dom": "^17.0.2",
|
|
32
|
+
"react": "^17.0.2"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"api:update": "cloudpack-scripts api-update",
|
|
36
|
+
"api": "cloudpack-scripts api",
|
|
37
|
+
"build:watch": "cloudpack-scripts build-watch",
|
|
38
|
+
"build": "cloudpack-scripts build",
|
|
39
|
+
"lint:update": "cloudpack-scripts lint-update",
|
|
40
|
+
"lint": "cloudpack-scripts lint",
|
|
41
|
+
"test:update": "cloudpack-scripts test-update",
|
|
42
|
+
"test:watch": "cloudpack-scripts test-watch",
|
|
43
|
+
"test": "cloudpack-scripts test"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"/lib"
|
|
47
|
+
]
|
|
48
|
+
}
|