@friggframework/devtools 2.0.0--canary.730.541f199.0 → 2.0.0--canary.730.f2ba24a.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/infrastructure/README.md +5 -5
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +6 -6
- package/infrastructure/domains/database/migration-builder.test.js +6 -6
- package/infrastructure/domains/integration/integration-builder.test.js +6 -6
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +4 -4
- package/infrastructure/domains/shared/utilities/nested-node-modules.js +6 -5
- package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +20 -26
- package/package.json +7 -7
package/infrastructure/README.md
CHANGED
|
@@ -285,23 +285,23 @@ const appDefinition = {
|
|
|
285
285
|
|
|
286
286
|
> ℹ️ When `usePrismaLambdaLayer: false`, Prisma stays inside each bundle and the runtime automatically loads the correct binary. No extra configuration is required.
|
|
287
287
|
|
|
288
|
-
**
|
|
288
|
+
**Nested node_modules in Lambda packages:**
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
npm nests a package under its dependant only when the root copy cannot satisfy the dependant's range. Function packages ship the dependency tree the way npm resolved it. Nested copies of `@friggframework/*`, `aws-sdk`, `@aws-sdk/*` and, when the Prisma layer is enabled, `@prisma/*` and `.prisma` are excluded: the app's single core, the Lambda runtime and the layer provide them.
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
An app can exclude every nested `node_modules` to make packages smaller:
|
|
293
293
|
|
|
294
294
|
```javascript
|
|
295
295
|
const appDefinition = {
|
|
296
296
|
name: 'my-app',
|
|
297
297
|
lambda: {
|
|
298
|
-
keepNestedNodeModules:
|
|
298
|
+
keepNestedNodeModules: false,
|
|
299
299
|
},
|
|
300
300
|
integrations: [{ Definition: { name: 'salesforce' } }],
|
|
301
301
|
};
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
With the opt-out, each nested package resolves whatever version is hoisted to the root, and a package whose root copy is a dev dependency is not shipped at all. The first `require` of such a package fails at Lambda init with `Runtime.ImportModuleError`.
|
|
305
305
|
|
|
306
306
|
## Usage Examples
|
|
307
307
|
|
|
@@ -1025,23 +1025,23 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1025
1025
|
result.functions.adminScriptRouter,
|
|
1026
1026
|
];
|
|
1027
1027
|
|
|
1028
|
-
it('
|
|
1028
|
+
it('keeps nested node_modules by default, still excluding nested Frigg copies', async () => {
|
|
1029
1029
|
const result = await new AdminScriptBuilder().build(appDefinition(), {});
|
|
1030
1030
|
|
|
1031
1031
|
for (const fn of executorAndRouter(result)) {
|
|
1032
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1032
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
1033
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1033
1034
|
}
|
|
1034
1035
|
});
|
|
1035
1036
|
|
|
1036
|
-
it('
|
|
1037
|
+
it('excludes every nested node_modules when the app opts out', async () => {
|
|
1037
1038
|
const result = await new AdminScriptBuilder().build(
|
|
1038
|
-
appDefinition({ keepNestedNodeModules:
|
|
1039
|
+
appDefinition({ keepNestedNodeModules: false }),
|
|
1039
1040
|
{}
|
|
1040
1041
|
);
|
|
1041
1042
|
|
|
1042
1043
|
for (const fn of executorAndRouter(result)) {
|
|
1043
|
-
expect(fn.package.exclude).
|
|
1044
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1044
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1045
1045
|
}
|
|
1046
1046
|
});
|
|
1047
1047
|
});
|
|
@@ -432,23 +432,23 @@ describe('MigrationBuilder nested node_modules (lambda.keepNestedNodeModules)',
|
|
|
432
432
|
result.functions.dbMigrationRouter,
|
|
433
433
|
];
|
|
434
434
|
|
|
435
|
-
it('
|
|
435
|
+
it('keeps nested node_modules by default, still excluding nested Frigg copies', async () => {
|
|
436
436
|
const result = await new MigrationBuilder().build(baseAppDefinition, {});
|
|
437
437
|
|
|
438
438
|
for (const fn of workerAndRouter(result)) {
|
|
439
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
439
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
440
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
440
441
|
}
|
|
441
442
|
});
|
|
442
443
|
|
|
443
|
-
it('
|
|
444
|
+
it('excludes every nested node_modules when the app opts out', async () => {
|
|
444
445
|
const result = await new MigrationBuilder().build(
|
|
445
|
-
{ ...baseAppDefinition, lambda: { keepNestedNodeModules:
|
|
446
|
+
{ ...baseAppDefinition, lambda: { keepNestedNodeModules: false } },
|
|
446
447
|
{}
|
|
447
448
|
);
|
|
448
449
|
|
|
449
450
|
for (const fn of workerAndRouter(result)) {
|
|
450
|
-
expect(fn.package.exclude).
|
|
451
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
451
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
454
|
});
|
|
@@ -1093,24 +1093,24 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1093
1093
|
const packagedFunctions = (result) =>
|
|
1094
1094
|
Object.values(result.functions).filter((fn) => fn.package?.exclude);
|
|
1095
1095
|
|
|
1096
|
-
it('
|
|
1096
|
+
it('keeps nested node_modules by default, still excluding nested Frigg copies', async () => {
|
|
1097
1097
|
const result = await new IntegrationBuilder().build(appDefinition(), {});
|
|
1098
1098
|
|
|
1099
1099
|
expect(packagedFunctions(result).length).toBeGreaterThan(0);
|
|
1100
1100
|
for (const fn of packagedFunctions(result)) {
|
|
1101
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1101
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
1102
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1102
1103
|
}
|
|
1103
1104
|
});
|
|
1104
1105
|
|
|
1105
|
-
it('
|
|
1106
|
+
it('excludes every nested node_modules when the app opts out', async () => {
|
|
1106
1107
|
const result = await new IntegrationBuilder().build(
|
|
1107
|
-
appDefinition({ keepNestedNodeModules:
|
|
1108
|
+
appDefinition({ keepNestedNodeModules: false }),
|
|
1108
1109
|
{}
|
|
1109
1110
|
);
|
|
1110
1111
|
|
|
1111
1112
|
for (const fn of packagedFunctions(result)) {
|
|
1112
|
-
expect(fn.package.exclude).
|
|
1113
|
-
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1113
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1114
1114
|
}
|
|
1115
1115
|
});
|
|
1116
1116
|
});
|
|
@@ -326,16 +326,16 @@ describe('Base Definition Factory', () => {
|
|
|
326
326
|
describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
327
327
|
const build = (appDefinition) => createBaseDefinition(appDefinition, {}, {}, true);
|
|
328
328
|
|
|
329
|
-
it('excludes every nested node_modules from the core function packages
|
|
330
|
-
const result = build({ name: 'test-app' });
|
|
329
|
+
it('excludes every nested node_modules from the core function packages when the app opts out', () => {
|
|
330
|
+
const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: false } });
|
|
331
331
|
|
|
332
332
|
for (const fn of ['auth', 'user', 'health']) {
|
|
333
333
|
expect(result.functions[fn].package.exclude).toContain('node_modules/**/node_modules/**');
|
|
334
334
|
}
|
|
335
335
|
});
|
|
336
336
|
|
|
337
|
-
it('keeps nested node_modules
|
|
338
|
-
const result = build({ name: 'test-app'
|
|
337
|
+
it('keeps nested node_modules by default, still excluding nested Frigg, AWS SDK and Prisma copies', () => {
|
|
338
|
+
const result = build({ name: 'test-app' });
|
|
339
339
|
|
|
340
340
|
for (const fn of ['auth', 'user', 'health']) {
|
|
341
341
|
const { exclude } = result.functions[fn].package;
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* npm nests a package only when the root copy cannot satisfy the dependant's
|
|
7
7
|
* range. Excluding every nested node_modules from a Lambda package therefore
|
|
8
8
|
* rewires module resolution to whatever is hoisted, and drops a package
|
|
9
|
-
* outright when the root copy is dev-only.
|
|
10
|
-
*
|
|
11
|
-
* copies of Frigg packages, the
|
|
12
|
-
* app's single core, the Lambda
|
|
9
|
+
* outright when the root copy is dev-only. Function packages ship the tree the
|
|
10
|
+
* way npm resolved it unless an app opts out with
|
|
11
|
+
* `lambda.keepNestedNodeModules: false`. Nested copies of Frigg packages, the
|
|
12
|
+
* AWS SDK and Prisma stay excluded because the app's single core, the Lambda
|
|
13
|
+
* runtime and the Prisma layer provide them.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
const ALL_NESTED_NODE_MODULES = 'node_modules/**/node_modules/**';
|
|
@@ -19,7 +20,7 @@ const ALL_NESTED_NODE_MODULES = 'node_modules/**/node_modules/**';
|
|
|
19
20
|
* @returns {boolean}
|
|
20
21
|
*/
|
|
21
22
|
function keepsNestedNodeModules(appDefinition = {}) {
|
|
22
|
-
return appDefinition.lambda?.keepNestedNodeModules
|
|
23
|
+
return appDefinition.lambda?.keepNestedNodeModules !== false;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -8,20 +8,13 @@ const {
|
|
|
8
8
|
nestedNodeModulesExcludes,
|
|
9
9
|
} = require('./nested-node-modules');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
it('excludes every nested node_modules by default', () => {
|
|
13
|
-
expect(nestedNodeModulesExcludes({}, true)).toEqual([
|
|
14
|
-
'node_modules/**/node_modules/**',
|
|
15
|
-
]);
|
|
16
|
-
expect(ALL_NESTED_NODE_MODULES).toBe('node_modules/**/node_modules/**');
|
|
17
|
-
});
|
|
11
|
+
const OPT_OUT = { lambda: { keepNestedNodeModules: false } };
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const excludes = nestedNodeModulesExcludes(appDefinition, true);
|
|
13
|
+
describe('nestedNodeModulesExcludes', () => {
|
|
14
|
+
it('keeps nested node_modules by default, except Frigg, AWS SDK and Prisma copies', () => {
|
|
15
|
+
const excludes = nestedNodeModulesExcludes({}, true);
|
|
23
16
|
|
|
24
|
-
expect(excludes).not.toContain(
|
|
17
|
+
expect(excludes).not.toContain(ALL_NESTED_NODE_MODULES);
|
|
25
18
|
expect(excludes).toEqual([
|
|
26
19
|
'node_modules/**/node_modules/@friggframework/**',
|
|
27
20
|
'node_modules/**/node_modules/aws-sdk/**',
|
|
@@ -32,30 +25,31 @@ describe('nestedNodeModulesExcludes', () => {
|
|
|
32
25
|
});
|
|
33
26
|
|
|
34
27
|
it('keeps nested Prisma copies when the app bundles Prisma instead of using the layer', () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const excludes = nestedNodeModulesExcludes(appDefinition, false);
|
|
38
|
-
|
|
39
|
-
expect(excludes).toEqual([
|
|
28
|
+
expect(nestedNodeModulesExcludes({}, false)).toEqual([
|
|
40
29
|
'node_modules/**/node_modules/@friggframework/**',
|
|
41
30
|
'node_modules/**/node_modules/aws-sdk/**',
|
|
42
31
|
'node_modules/**/node_modules/@aws-sdk/**',
|
|
43
32
|
]);
|
|
44
33
|
});
|
|
34
|
+
|
|
35
|
+
it('excludes every nested node_modules when the app opts out', () => {
|
|
36
|
+
expect(nestedNodeModulesExcludes(OPT_OUT, true)).toEqual([
|
|
37
|
+
'node_modules/**/node_modules/**',
|
|
38
|
+
]);
|
|
39
|
+
expect(ALL_NESTED_NODE_MODULES).toBe('node_modules/**/node_modules/**');
|
|
40
|
+
});
|
|
45
41
|
});
|
|
46
42
|
|
|
47
43
|
describe('keepsNestedNodeModules', () => {
|
|
48
|
-
it('is only
|
|
49
|
-
expect(
|
|
50
|
-
keepsNestedNodeModules({ lambda: { keepNestedNodeModules: true } })
|
|
51
|
-
).toBe(true);
|
|
44
|
+
it('is only disabled by the boolean false', () => {
|
|
45
|
+
expect(keepsNestedNodeModules(OPT_OUT)).toBe(false);
|
|
52
46
|
expect(
|
|
53
47
|
keepsNestedNodeModules({
|
|
54
|
-
lambda: { keepNestedNodeModules:
|
|
48
|
+
lambda: { keepNestedNodeModules: true },
|
|
55
49
|
})
|
|
56
|
-
).toBe(
|
|
57
|
-
expect(keepsNestedNodeModules({ lambda: {} })).toBe(
|
|
58
|
-
expect(keepsNestedNodeModules({})).toBe(
|
|
59
|
-
expect(keepsNestedNodeModules()).toBe(
|
|
50
|
+
).toBe(true);
|
|
51
|
+
expect(keepsNestedNodeModules({ lambda: {} })).toBe(true);
|
|
52
|
+
expect(keepsNestedNodeModules({})).toBe(true);
|
|
53
|
+
expect(keepsNestedNodeModules()).toBe(true);
|
|
60
54
|
});
|
|
61
55
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.730.
|
|
4
|
+
"version": "2.0.0--canary.730.f2ba24a.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@babel/eslint-parser": "^7.18.9",
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
|
-
"@friggframework/core": "2.0.0--canary.730.
|
|
32
|
-
"@friggframework/schemas": "2.0.0--canary.730.
|
|
33
|
-
"@friggframework/test": "2.0.0--canary.730.
|
|
31
|
+
"@friggframework/core": "2.0.0--canary.730.f2ba24a.0",
|
|
32
|
+
"@friggframework/schemas": "2.0.0--canary.730.f2ba24a.0",
|
|
33
|
+
"@friggframework/test": "2.0.0--canary.730.f2ba24a.0",
|
|
34
34
|
"@hapi/boom": "^10.0.1",
|
|
35
35
|
"@inquirer/prompts": "^5.3.8",
|
|
36
36
|
"axios": "^1.18.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"validate-npm-package-name": "^5.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@friggframework/eslint-config": "2.0.0--canary.730.
|
|
62
|
-
"@friggframework/prettier-config": "2.0.0--canary.730.
|
|
61
|
+
"@friggframework/eslint-config": "2.0.0--canary.730.f2ba24a.0",
|
|
62
|
+
"@friggframework/prettier-config": "2.0.0--canary.730.f2ba24a.0",
|
|
63
63
|
"aws-sdk-client-mock": "^4.1.0",
|
|
64
64
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
65
65
|
"jest": "^30.1.3",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "f2ba24a33f80389cf136570c132f04e7a38c3c72"
|
|
95
95
|
}
|