@architect/inventory 3.2.1 → 3.3.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/changelog.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
## [3.3.0] 2022-09-06
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Node 14+ Lambda handler selection now defaults to ESM (unless otherwise specified)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## [3.2.2] 2022-08-20
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Enabled `hydrate` plugin API support
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
5
21
|
## [3.2.1] 2022-08-10
|
|
6
22
|
|
|
7
23
|
### Changed
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ let { is, normalizeSrc, pragmas, tidyError, validationPatterns } = require('../.
|
|
|
4
4
|
let { lambdas } = pragmas
|
|
5
5
|
let nonLambdaSetters = [ 'customLambdas', 'env', 'proxy', 'runtimes', 'shared', 'static', 'views', 'tables', 'tables-indexes' ]
|
|
6
6
|
let setters = [ ...lambdas, ...nonLambdaSetters ]
|
|
7
|
-
let pluginMethods = [ 'deploy', 'sandbox' ]
|
|
7
|
+
let pluginMethods = [ 'deploy', 'hydrate', 'sandbox' ]
|
|
8
8
|
let reservedNames = [ '_methods' ]
|
|
9
9
|
|
|
10
10
|
module.exports = function getPluginModules ({ arc, inventory, errors }) {
|
|
@@ -32,6 +32,7 @@ module.exports = function getHandler ({ config, src, build, errors }) {
|
|
|
32
32
|
return handlerConfig
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
// As of nodejs14.x, CJS remains the default over ESM when both are present
|
|
35
36
|
let nodeHandlers = [ 'index.js', 'index.mjs', 'index.cjs' ]
|
|
36
37
|
let denoHandlers = [ 'mod.ts', 'mod.js' ]
|
|
37
38
|
// TODO: these are all prob going away
|
|
@@ -43,14 +44,22 @@ function getExt ({ runtime, src, errors }) {
|
|
|
43
44
|
if (runtime === 'nodejs12.x') {
|
|
44
45
|
return { ext: 'js', handlerModuleSystem: 'cjs' }
|
|
45
46
|
}
|
|
46
|
-
// This presumes Node.js 14
|
|
47
|
+
// This presumes Node.js ≥14 Lambda releases use the same CJS/ESM pattern
|
|
48
|
+
// Generally in Lambda: CJS wins, but in Architect-land we attempt to default to ESM
|
|
47
49
|
else {
|
|
48
|
-
let { file, ext = '
|
|
50
|
+
let { file, ext = 'mjs' } = findHandler(nodeHandlers, src)
|
|
49
51
|
let handlerModuleSystem = ext === 'mjs' ? 'esm' : 'cjs'
|
|
50
52
|
let pkgFile = join(src, 'package.json')
|
|
51
53
|
if (existsSync(pkgFile)) {
|
|
52
54
|
let pkg = JSON.parse(readFileSync(pkgFile))
|
|
53
|
-
|
|
55
|
+
|
|
56
|
+
/**/ if (pkg?.type === 'module') handlerModuleSystem = 'esm'
|
|
57
|
+
else if (pkg?.type === 'commonjs') handlerModuleSystem = 'cjs'
|
|
58
|
+
else if (pkg?.type) throw Error(`Invalid 'type' field: ${pkg.type}`)
|
|
59
|
+
else handlerModuleSystem = 'cjs' // Lambda's default, not ours
|
|
60
|
+
|
|
61
|
+
// We always get to make this a .js file, even if it's ESM!
|
|
62
|
+
ext = 'js'
|
|
54
63
|
}
|
|
55
64
|
return { file, ext, handlerModuleSystem }
|
|
56
65
|
}
|
|
@@ -78,10 +87,3 @@ function findHandler (arr, src){
|
|
|
78
87
|
}
|
|
79
88
|
return {}
|
|
80
89
|
}
|
|
81
|
-
|
|
82
|
-
function getModSystem (pkg) {
|
|
83
|
-
if (pkg?.type === 'module') return 'esm'
|
|
84
|
-
else if (pkg?.type === 'commonjs') return 'cjs'
|
|
85
|
-
else if (pkg?.type) throw Error(`Invalid 'type' field: ${pkg.type}`)
|
|
86
|
-
return 'cjs'
|
|
87
|
-
}
|