-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
70 lines (68 loc) · 1.84 KB
/
Copy pathrollup.config.mjs
File metadata and controls
70 lines (68 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import ts from '@rollup/plugin-typescript';
import { transform } from 'typescript';
export default [
target({ input: './builders/t9n/index.ts', exports: 'named' }),
target({ input: './bin/index.ts' }),
target({ input: './server/index.ts' }),
target({ input: './schematics/ng-add/index.ts' }),
target({ input: './schematics/resolve-ng-locales/index.ts' }),
];
function target({ input, exports = 'auto' }) {
return {
input,
output: {
file: input.replace(/\.ts$/, '.cjs'),
exports,
format: 'cjs',
},
external: [
'@angular-devkit/architect',
'@angular-devkit/core',
'@angular-devkit/core/node',
'@angular-devkit/schematics',
'@nestjs/common',
'@nestjs/core',
'@nestjs/platform-ws',
'@nestjs/websockets',
'@nestjs/serve-static',
'@schematics/angular/utility/workspace',
'@schematics/angular/utility/workspace-models',
'@xmldom/xmldom',
'class-validator',
'fs',
'js-levenshtein',
'os',
'path',
'rxjs',
'rxjs/operators',
'util',
'../../../server/index',
'../../server/index',
'../server/index',
],
plugins: [
ts({
tsconfig: 'tsconfig.node.json',
exclude: ['**/*.spec.ts'],
}),
{
name: 'cjs-fix',
generateBundle(options, bundle) {
Object.values(bundle).forEach((chunk) => {
if (chunk.imports.some((i) => i.startsWith('.'))) {
chunk.code = chunk.code.replace(
/require\((['"])(\.[^'"]+)\1\)/g,
(match, quote, path) => {
if (!path.endsWith('.cjs')) {
return `require(${quote}${path}.cjs${quote})`;
}
return match;
},
);
}
});
},
},
],
};
}