requirejs-esm 2.2.0 → 2.2.1
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/dist/api.js +10 -5
- package/dist/api.js.map +1 -1
- package/dist/plugin.js +10 -5
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -4
- package/src/api.d.ts +3 -0
- package/src/transformer/amd.js +10 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "requirejs-esm",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A RequireJS plugin converting JavaScript modules from ESM to AMD.",
|
|
5
5
|
"author": "Ferdinand Prantl <prantlf@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -94,15 +94,15 @@
|
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@prantlf/requirejs": "^3.0.0",
|
|
97
|
-
"@rollup/plugin-commonjs": "^22.0.
|
|
97
|
+
"@rollup/plugin-commonjs": "^22.0.1",
|
|
98
98
|
"@rollup/plugin-json": "^4.1.0",
|
|
99
99
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
100
100
|
"@semantic-release/changelog": "^6.0.1",
|
|
101
101
|
"@semantic-release/git": "^10.0.1",
|
|
102
102
|
"c8": "^7.11.3",
|
|
103
|
-
"eslint": "^8.
|
|
103
|
+
"eslint": "^8.19.0",
|
|
104
104
|
"lit-html": "^1",
|
|
105
|
-
"rollup": "^2.
|
|
105
|
+
"rollup": "^2.76.0",
|
|
106
106
|
"tehanu": "^1.0.1",
|
|
107
107
|
"tehanu-repo-coco": "^1.0.0",
|
|
108
108
|
"tehanu-teru": "^1.0.0",
|
package/src/api.d.ts
CHANGED
package/src/transformer/amd.js
CHANGED
|
@@ -37,16 +37,21 @@ function detectDefineOrRequireCall(expr) {
|
|
|
37
37
|
if (length <= ++index) return false
|
|
38
38
|
arg = args[index]
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if (arg.type === 'FunctionExpression' || arg.type === 'ArrowFunctionExpression') {
|
|
41
|
+
return { namespace, func, name, deps, factory: arg }
|
|
42
|
+
}
|
|
43
|
+
return arg.type === 'ObjectExpression' && { namespace, func, name, deps, output: arg }
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// require([deps], success, error)
|
|
46
47
|
if (func.name === 'require') {
|
|
47
48
|
const deps = args[0]
|
|
48
|
-
|
|
49
|
-
args[1]
|
|
49
|
+
if (deps.type === 'ArrayExpression' && length >= 2) {
|
|
50
|
+
const body = args[1]
|
|
51
|
+
if (body.type === 'FunctionExpression' || body.type === 'ArrowFunctionExpression') {
|
|
52
|
+
return { func, deps, body }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
|