Skip to content

Commit 84a0109

Browse files
authored
refactor(migrations): update module output, drop dynamic import helper (#17184)
1 parent 454d4e6 commit 84a0109

File tree

16 files changed

+42
-65
lines changed

16 files changed

+42
-65
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

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

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) {

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

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

1210
const version = '13.1.0';
1311

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

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

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import type {
33
SchematicContext,
44
Tree
55
} from '@angular-devkit/schematics';
6-
import type { Element } from '@angular/compiler';
7-
// use bare specifier to escape the schematics encapsulation for the dynamic import:
8-
import { nativeImport } from 'igniteui-angular/migrations/common/import-helper.js';
6+
import type { Element } from '@angular/compiler' with { "resolution-mode": "import" };
97
import type { Options } from '../../schematics/interfaces/options';
108
import { BoundPropertyObject, InputPropertyType, UpdateChanges } from '../common/UpdateChanges';
119
import { FileChange, findElementNodes, getAttribute, getSourceOffset, parseFile, hasAttribute } from '../common/util';
@@ -15,7 +13,8 @@ const version = '15.1.0';
1513
export default (options: Options): Rule => async (host: Tree, context: SchematicContext) => {
1614
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);
1715

18-
const { HtmlParser } = await nativeImport('@angular/compiler') as typeof import('@angular/compiler');
16+
// bare specifier escapes schematics encapsulation for the compiler dynamic import:
17+
const { HtmlParser } = await import('@angular/compiler');
1918
const update = new UpdateChanges(__dirname, host, context);
2019
const cardsToMigrate = new Set<any>();
2120
const CARD_ACTIONS = ['igx-card-actions'];

0 commit comments

Comments
 (0)