Skip to content

Commit 024b8e8

Browse files
authored
Merge pull request #17183 from IgniteUI/sstoychev/fix-migrations-ng21
Fix migrations & schematics commonjs type for latest package, adjust module output
2 parents b1eb339 + 69dda0b commit 024b8e8

File tree

19 files changed

+51
-66
lines changed

19 files changed

+51
-66
lines changed

gulpfile.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ module.exports.copyMigrations = (cb) => {
6262
'!**/tsconfig.json'
6363
]).pipe(gulp.dest('./dist/igniteui-angular/migrations'));
6464

65-
66-
gulp.src([
67-
'./projects/igniteui-angular/migrations/common/import-helper.js'
68-
]).pipe(gulp.dest('./dist/igniteui-angular/migrations/common'));
69-
7065
cb();
7166
};
7267

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# Nested package.json's are only needed for development.
2-
**/package.json
2+
**/package.json
3+
!migrations/package.json
4+
!schematics/package.json

projects/igniteui-angular/migrations/common/import-helper.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

projects/igniteui-angular/migrations/common/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import type {
1919
Node,
2020
Text,
2121
Visitor
22-
} from '@angular/compiler';
22+
} from '@angular/compiler' with { "resolution-mode": "import" };
2323

2424
const configPaths = ['/.angular.json', '/angular.json'];
2525

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

projects/igniteui-angular/migrations/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
2+
"ts-node": {
3+
"compilerOptions": {
4+
// explicitly force ts-node into CommonJS mode, otherwise spies on modules like `fs` fail as those are not configurable in ESM context
5+
"module": "CommonJS"
6+
}
7+
},
28
"compilerOptions": {
39
"target": "es6",
4-
"module": "commonjs",
10+
"module": "node16",
511
"sourceMap": false,
612
"declaration": true,
713
"outDir": "../../../dist/igniteui-angular/migrations",

projects/igniteui-angular/migrations/update-11_0_0/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import type { Element } from '@angular/compiler';
1+
import type { Element } from '@angular/compiler' with { "resolution-mode": "import" };
22
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
33
import { UpdateChanges } from '../common/UpdateChanges';
44
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile, serializeNodes } from '../common/util';
5-
// use bare specifier to escape the schematics encapsulation for the dynamic import:
6-
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
75

86
const version = '11.0.0';
97

108
export default (): Rule => async (host: Tree, context: SchematicContext) => {
119
context.logger.info(
1210
`Applying migration for Ignite UI for Angular to version ${version}`
1311
);
14-
const { HtmlParser, getHtmlTagDefinition } = await nativeImport('@angular/compiler') as typeof import('@angular/compiler');
12+
// bare specifier escapes schematics encapsulation for the compiler dynamic import:
13+
const { HtmlParser, getHtmlTagDefinition } = await import('@angular/compiler');
1514

1615
const update = new UpdateChanges(__dirname, host, context);
1716

projects/igniteui-angular/migrations/update-12_0_0/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import type { Element } from '@angular/compiler';
1+
import type { Element } from '@angular/compiler' with { "resolution-mode": "import" };
22
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
33
import { UpdateChanges } from '../common/UpdateChanges';
44
import { FileChange, getAttribute, findElementNodes, getSourceOffset, hasAttribute, parseFile } from '../common/util';
5-
// use bare specifier to escape the schematics encapsulation for the dynamic import:
6-
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
7-
import { Options } from '../../schematics/interfaces/options';
5+
import type { Options } from '../../schematics/interfaces/options';
86

97
const version = '12.0.0';
108

@@ -14,7 +12,8 @@ export default (options: Options): Rule =>
1412
`Applying migration for Ignite UI for Angular to version ${version}`
1513
);
1614

17-
const { HtmlParser } = await nativeImport('@angular/compiler') as typeof import('@angular/compiler');
15+
// bare specifier escapes schematics encapsulation for the compiler dynamic import:
16+
const { HtmlParser } = await import('@angular/compiler');
1817

1918
// eslint-disable-next-line max-len
2019
const UPDATE_NOTE = `<!--NOTE: This component has been updated by Infragistics migration: v${version}\nPlease check your template whether all bindings/event handlers are correct.-->\n`;

projects/igniteui-angular/migrations/update-12_1_0/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import type { Element } from '@angular/compiler';
1+
import type { Element } from '@angular/compiler' with { "resolution-mode": "import" };
22
import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
33
import { UpdateChanges } from '../common/UpdateChanges';
44
import {
55
FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile,
66
serializeNodes, makeNgIf, stringifyAttributes
77
} from '../common/util';
8-
// use bare specifier to escape the schematics encapsulation for the dynamic import:
9-
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
108

119
const version = '12.1.0';
1210

1311
export default (): Rule => async (host: Tree, context: SchematicContext) => {
1412
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);
1513

16-
const { HtmlParser, getHtmlTagDefinition } = await nativeImport('@angular/compiler') as typeof import('@angular/compiler');
14+
// bare specifier escapes schematics encapsulation for the compiler dynamic import:
15+
const { HtmlParser, getHtmlTagDefinition } = await import('@angular/compiler');
1716

1817
const update = new UpdateChanges(__dirname, host, context);
1918
const TAGS = ['igx-grid', 'igx-tree-grid', 'igx-hierarchical-grid'];

projects/igniteui-angular/migrations/update-13_0_0/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Element, Text } from '@angular/compiler';
1+
import type { Element, Text } from '@angular/compiler' with { "resolution-mode": "import" };
22
import type {
33
Rule,
44
SchematicContext,
@@ -7,8 +7,6 @@ import type {
77
import type { Options } from '../../schematics/interfaces/options';
88
import { UpdateChanges } from '../common/UpdateChanges';
99
import { FileChange, findElementNodes, getAttribute, getSourceOffset, hasAttribute, parseFile } from '../common/util';
10-
// use bare specifier to escape the schematics encapsulation for the dynamic import:
11-
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
1210

1311
const version = '13.0.0';
1412

@@ -27,7 +25,8 @@ export default (options: Options): Rule =>
2725
'[exportExcel]', 'exportExcel', '[exportExcelText]', 'exportExcelText',
2826
'[exportCsv]', 'exportCsv', '[exportCsvText]', 'exportCsvText', '[exportText]', 'exportText'];
2927
const actionsLeft = ['igx-grid-toolbar-advanced-filtering'];
30-
const { HtmlParser } = await nativeImport('@angular/compiler') as typeof import('@angular/compiler');
28+
// bare specifier escapes schematics encapsulation for the compiler dynamic import:
29+
const { HtmlParser } = await import('@angular/compiler');
3130

3231
const moduleTsFiles = tsFiles.filter(x => x.endsWith('.module.ts'));
3332
for (const path of moduleTsFiles) {

0 commit comments

Comments
 (0)