@things-factory/shell 10.1.155 → 10.1.157
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/bin/things-factory-migration +1 -1
- package/dist-server/initializers/database.js +5 -5
- package/dist-server/initializers/database.js.map +1 -1
- package/dist-server/initializers/ormconfig.d.ts +14 -2
- package/dist-server/initializers/ormconfig.js +36 -20
- package/dist-server/initializers/ormconfig.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/tests/import-loads-no-module.test.ts +37 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/shell",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.157",
|
|
4
4
|
"description": "Core module for framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"things-factory": "bin/things-factory",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"pg": "^8.7.3",
|
|
143
143
|
"sqlite3": "^5.0.8"
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "bde810f804966549a7041457ad7ede40fcb78488"
|
|
146
146
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Importing shell loads no other things-factory module.
|
|
3
|
+
*
|
|
4
|
+
* Most modules import shell themselves. When shell collected their entities at import time, each of them
|
|
5
|
+
* received shell's exports half-built, threw at its own top level and was dropped from the require cache;
|
|
6
|
+
* under Node 25 an ESM entry that imported shell and then one of those modules died with
|
|
7
|
+
* ERR_INTERNAL_ASSERTION. The modules are collected when the database is initialized (`ormconfig()`), once.
|
|
8
|
+
*/
|
|
9
|
+
const mockModule = '@things-factory/some-module'
|
|
10
|
+
const mockLoaded: string[] = []
|
|
11
|
+
|
|
12
|
+
/* The root project's stand-in for the application's environment, with one module in it. */
|
|
13
|
+
jest.mock('@things-factory/env', () => ({
|
|
14
|
+
...jest.requireActual('../../../test/__mocks__/env-mock.js'),
|
|
15
|
+
orderedModuleNames: [mockModule],
|
|
16
|
+
loader: (name: string) => {
|
|
17
|
+
mockLoaded.push(name)
|
|
18
|
+
return { entities: [class SomeEntity {}], migrations: [], subscribers: [] }
|
|
19
|
+
}
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
test('importing shell loads no module of the application', () => {
|
|
23
|
+
require('../server/index')
|
|
24
|
+
|
|
25
|
+
expect(mockLoaded).toEqual([])
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test('ormconfig() loads the modules when it is called, and only once', () => {
|
|
29
|
+
const { ormconfig } = require('../server/initializers/ormconfig')
|
|
30
|
+
|
|
31
|
+
const first = ormconfig()
|
|
32
|
+
const second = ormconfig()
|
|
33
|
+
|
|
34
|
+
expect(first.entities).toHaveLength(1)
|
|
35
|
+
expect(second).toBe(first)
|
|
36
|
+
expect(mockLoaded).toEqual([mockModule, mockModule, mockModule])
|
|
37
|
+
})
|