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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "requirejs-esm",
3
- "version": "2.2.0",
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.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.17.0",
103
+ "eslint": "^8.19.0",
104
104
  "lit-html": "^1",
105
- "rollup": "^2.75.6",
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
@@ -20,6 +20,9 @@ declare function detectDefinesOrRequires(ast: object): {
20
20
  func: object
21
21
  name?: object
22
22
  deps?: object[]
23
+ factory?: object
24
+ output?: object
25
+ body?: object
23
26
  }[]
24
27
 
25
28
  declare function detectImportsAndExports(ast: object): {
@@ -37,16 +37,21 @@ function detectDefineOrRequireCall(expr) {
37
37
  if (length <= ++index) return false
38
38
  arg = args[index]
39
39
  }
40
- return (arg.type === 'FunctionExpression' ||
41
- arg.type === 'ArrowFunctionExpression' ||
42
- arg.type === 'ObjectExpression') && { namespace, func, name, deps }
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
- return deps.type === 'ArrayExpression' && length >= 2 &&
49
- args[1].type === 'FunctionExpression' && { func, deps }
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