Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt Typescript ESM resolution mode #1190

Merged
merged 8 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 36 additions & 0 deletions .changeset/angry-owls-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
'@finos/eslint-plugin-legend-studio': major
'@finos/legend-application': major
'@finos/legend-art': major
'@finos/legend-dev-utils': major
'@finos/legend-extension-dsl-data-space': major
'@finos/legend-extension-dsl-diagram': major
'@finos/legend-extension-dsl-persistence': major
'@finos/legend-extension-dsl-text': major
'@finos/legend-extension-external-format-json-schema': major
'@finos/legend-extension-external-language-morphir': major
'@finos/legend-extension-external-store-service': major
'@finos/legend-extension-mapping-generation': major
'@finos/legend-graph': major
'@finos/legend-graph-extension-collection': major
'@finos/legend-manual-tests': major
'@finos/legend-model-storage': major
'@finos/legend-query': major
'@finos/legend-server-depot': major
'@finos/legend-server-sdlc': major
'@finos/legend-shared': major
'@finos/legend-studio': major
'@finos/legend-studio-extension-management-toolkit': major
'@finos/legend-studio-extension-query-builder': major
'@finos/legend-taxonomy': major
'@finos/legend-tracer-extension-zipkin': major
---

**BREAKING CHANGE:** Use `NodeNext` (`ESM` module resolution strategy for `Typescript`). Read more about this [here](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#esm-nodejs). This transition would be relatively smooth, except that we must use `ESM`-styled import (with extensions) for relative path. For example:

```ts
// before
import { someFunction } from './Utils';
// after
import { someFunction } from './Utils.js';
```
21 changes: 21 additions & 0 deletions .changeset/chatty-pens-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@finos/legend-application': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-graph': patch
'@finos/legend-manual-tests': patch
'@finos/legend-query': patch
'@finos/legend-query-deployment': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-studio': patch
'@finos/legend-studio-deployment': patch
'@finos/legend-studio-extension-query-builder': patch
'@finos/legend-taxonomy-deployment': patch
---
32 changes: 32 additions & 0 deletions .changeset/dirty-badgers-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
'@finos/legend-application': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-format-json-schema': patch
'@finos/legend-extension-external-language-morphir': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-extension-mapping-generation': patch
'@finos/legend-graph': patch
'@finos/legend-graph-extension-collection': patch
'@finos/legend-manual-tests': patch
'@finos/legend-model-storage': patch
'@finos/legend-query': patch
'@finos/legend-query-app': patch
'@finos/legend-query-deployment': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-studio': patch
'@finos/legend-studio-app': patch
'@finos/legend-studio-deployment': patch
'@finos/legend-studio-extension-management-toolkit': patch
'@finos/legend-studio-extension-query-builder': patch
'@finos/legend-taxonomy': patch
'@finos/legend-taxonomy-app': patch
'@finos/legend-taxonomy-deployment': patch
'@finos/legend-tracer-extension-zipkin': patch
---
6 changes: 6 additions & 0 deletions .changeset/eight-colts-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@finos/legend-shared': major
'@finos/legend-dev-utils': major
---

**BREAKING CHANGE:** Use `@jest/globals` to import `jest` constructs, such as, `expect`, `test`, etc. We bumped into some problem when trying to disable `injectGlobals` in `Jest` config, so that would be left on as default for now, but at least with this change, we restrict usage of `jest` globals in the codebase.
5 changes: 5 additions & 0 deletions .changeset/four-knives-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@finos/legend-dev-utils': major
---

**BREAKING CHANGE:** Cleanup `Webpack` configuration utility: removed field `extraBabelLoaderIncludePatterns`.
33 changes: 33 additions & 0 deletions .changeset/hip-carpets-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@finos/eslint-plugin-legend-studio': patch
'@finos/legend-application': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-format-json-schema': patch
'@finos/legend-extension-external-language-morphir': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-extension-mapping-generation': patch
'@finos/legend-graph': patch
'@finos/legend-graph-extension-collection': patch
'@finos/legend-manual-tests': patch
'@finos/legend-model-storage': patch
'@finos/legend-query': patch
'@finos/legend-query-app': patch
'@finos/legend-query-deployment': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-studio': patch
'@finos/legend-studio-app': patch
'@finos/legend-studio-deployment': patch
'@finos/legend-studio-extension-management-toolkit': patch
'@finos/legend-studio-extension-query-builder': patch
'@finos/legend-taxonomy': patch
'@finos/legend-taxonomy-app': patch
'@finos/legend-taxonomy-deployment': patch
'@finos/legend-tracer-extension-zipkin': patch
---
29 changes: 29 additions & 0 deletions .changeset/popular-coins-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@finos/legend-application': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-format-json-schema': patch
'@finos/legend-extension-external-language-morphir': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-extension-mapping-generation': patch
'@finos/legend-graph': patch
'@finos/legend-graph-extension-collection': patch
'@finos/legend-manual-tests': patch
'@finos/legend-model-storage': patch
'@finos/legend-query': patch
'@finos/legend-query-deployment': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-studio': patch
'@finos/legend-studio-deployment': patch
'@finos/legend-studio-extension-management-toolkit': patch
'@finos/legend-studio-extension-query-builder': patch
'@finos/legend-taxonomy': patch
'@finos/legend-taxonomy-deployment': patch
'@finos/legend-tracer-extension-zipkin': patch
---
33 changes: 33 additions & 0 deletions .changeset/six-mails-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@finos/eslint-plugin-legend-studio': patch
'@finos/legend-application': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-format-json-schema': patch
'@finos/legend-extension-external-language-morphir': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-extension-mapping-generation': patch
'@finos/legend-graph': patch
'@finos/legend-graph-extension-collection': patch
'@finos/legend-manual-tests': patch
'@finos/legend-model-storage': patch
'@finos/legend-query': patch
'@finos/legend-query-app': patch
'@finos/legend-query-deployment': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-studio': patch
'@finos/legend-studio-app': patch
'@finos/legend-studio-deployment': patch
'@finos/legend-studio-extension-management-toolkit': patch
'@finos/legend-studio-extension-query-builder': patch
'@finos/legend-taxonomy': patch
'@finos/legend-taxonomy-app': patch
'@finos/legend-taxonomy-deployment': patch
'@finos/legend-tracer-extension-zipkin': patch
---
33 changes: 33 additions & 0 deletions .changeset/yellow-snakes-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@finos/eslint-plugin-legend-studio': patch
'@finos/legend-application': patch
'@finos/legend-art': patch
'@finos/legend-dev-utils': patch
'@finos/legend-extension-dsl-data-space': patch
'@finos/legend-extension-dsl-diagram': patch
'@finos/legend-extension-dsl-persistence': patch
'@finos/legend-extension-dsl-text': patch
'@finos/legend-extension-external-format-json-schema': patch
'@finos/legend-extension-external-language-morphir': patch
'@finos/legend-extension-external-store-service': patch
'@finos/legend-extension-mapping-generation': patch
'@finos/legend-graph': patch
'@finos/legend-graph-extension-collection': patch
'@finos/legend-manual-tests': patch
'@finos/legend-model-storage': patch
'@finos/legend-query': patch
'@finos/legend-query-app': patch
'@finos/legend-query-deployment': patch
'@finos/legend-server-depot': patch
'@finos/legend-server-sdlc': patch
'@finos/legend-shared': patch
'@finos/legend-studio': patch
'@finos/legend-studio-app': patch
'@finos/legend-studio-deployment': patch
'@finos/legend-studio-extension-management-toolkit': patch
'@finos/legend-studio-extension-query-builder': patch
'@finos/legend-taxonomy': patch
'@finos/legend-taxonomy-app': patch
'@finos/legend-taxonomy-deployment': patch
'@finos/legend-tracer-extension-zipkin': patch
---
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![FINOS - Incubating](https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg)](https://finosfoundation.atlassian.net/wiki/display/FINOS/Incubating)
[![npm](https://img.shields.io/npm/v/@finos/legend-studio-app)](https://www.npmjs.com/package/@finos/legend-studio-app)
![build](https://github.com/finos/legend-studio/actions/workflows/check-build.yml/badge.svg)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=legend-studio&metric=security_rating&token=1649412014267d7d7a6833643cb3133afe0137b0)](https://sonarcloud.io/dashboard?id=legend-studio)

Expand Down
14 changes: 12 additions & 2 deletions fixtures/legend-mock-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,18 @@
* limitations under the License.
*/

import Fastify from 'fastify';
import FastifyCORS from '@fastify/cors';
/**
* Previously, these exports rely on ES module interop to expose `default` export
* properly. But since we use `ESM` for Typescript resolution now, we lose this
*
* TODO: remove these when the package properly work with Typescript's nodenext
* module resolution
*
* @workaround ESM
* See https://github.com/microsoft/TypeScript/issues/49298
*/
import { default as Fastify } from 'fastify';
import { default as FastifyCORS } from '@fastify/cors';
import TAXONOMY_TREE_DATA from './TEST_DATA__TaxonomyTreeData.json' assert { type: 'json' };

const PORT = 60001;
Expand Down
2 changes: 1 addition & 1 deletion fixtures/legend-mock-server/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"compilerOptions": {
"tsBuildInfoFile": "build/prod.tsbuildinfo"
},
"exclude": ["src/**/__tests__/**/*.ts", "src/**/__mocks__/**/*.ts"]
"exclude": ["src/**/__tests__/**/*.*", "src/**/__mocks__/**/*.*"]
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"@finos/eslint-plugin-legend-studio": "workspace:*",
"@finos/legend-dev-utils": "workspace:*",
"@finos/stylelint-config-legend-studio": "workspace:*",
"@types/jest": "27.5.1",
"@types/node": "17.0.38",
"chalk": "5.0.1",
"cross-env": "7.0.3",
Expand All @@ -97,7 +96,7 @@
"husky": "8.0.1",
"inquirer": "8.2.4",
"jest": "28.1.0",
"lint-staged": "12.5.0",
"lint-staged": "13.0.0",
"micromatch": "4.0.5",
"npm-run-all": "4.1.5",
"prettier": "2.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/

module.exports = require('./src/index');
module.exports = require('./src/index.js');
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const IMPORT_RULES = {
'import/namespace': OFF,
'import/default': OFF,
'import/export': OFF,
// Enforce ESM-styled imports
'import/extensions': [ERROR, 'always', { ignorePackages: true }],
'import/newline-after-import': [WARN, { count: 1 }],
'import/no-default-export': WARN,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/configs/scripts-override.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

const COMPUTATIONALLY_EXPENSIVE_RULES =
require('./computationally-expensive').rules;
require('./computationally-expensive.js').rules;

const OFF = 0;

Expand Down
24 changes: 12 additions & 12 deletions packages/eslint-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

module.exports = {
configs: {
'computationally-expensive': require('./configs/computationally-expensive')
.config,
recommended: require('./configs/recommended').config,
'scripts-override': require('./configs/scripts-override').config,
'computationally-expensive':
require('./configs/computationally-expensive.js').config,
recommended: require('./configs/recommended.js').config,
'scripts-override': require('./configs/scripts-override.js').config,
},
rules: {
'enforce-module-import-hierarchy': require('./rules/enforce-module-import-hierarchy'),
'enforce-protocol-export-prefix': require('./rules/enforce-protocol-export-prefix'),
'enforce-protocol-file-prefix': require('./rules/enforce-protocol-file-prefix'),
'no-cross-protocol-version-import': require('./rules/no-cross-protocol-version-import'),
'no-cross-workspace-non-export-usage': require('./rules/no-cross-workspace-non-export-usage'),
'no-cross-workspace-source-usage': require('./rules/no-cross-workspace-source-usage'),
'no-same-workspace-absolute-import': require('./rules/no-same-workspace-absolute-import'),
'no-same-workspace-index-import': require('./rules/no-same-workspace-index-import'),
'enforce-module-import-hierarchy': require('./rules/enforce-module-import-hierarchy.js'),
'enforce-protocol-export-prefix': require('./rules/enforce-protocol-export-prefix.js'),
'enforce-protocol-file-prefix': require('./rules/enforce-protocol-file-prefix.js'),
'no-cross-protocol-version-import': require('./rules/no-cross-protocol-version-import.js'),
'no-cross-workspace-non-export-usage': require('./rules/no-cross-workspace-non-export-usage.js'),
'no-cross-workspace-source-usage': require('./rules/no-cross-workspace-source-usage.js'),
'no-same-workspace-absolute-import': require('./rules/no-same-workspace-absolute-import.js'),
'no-same-workspace-index-import': require('./rules/no-same-workspace-index-import.js'),
},
};
1 change: 1 addition & 0 deletions packages/legend-application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
},
"devDependencies": {
"@finos/legend-dev-utils": "workspace:*",
"@jest/globals": "28.1.0",
"cross-env": "7.0.3",
"eslint": "8.16.0",
"jest": "28.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

import { configure as configureMobx } from 'mobx';
import { editor as monacoEditorAPI } from 'monaco-editor';
import { MONOSPACED_FONT_FAMILY } from '../const';
import { MONOSPACED_FONT_FAMILY } from '../const.js';
import type {
LegendApplicationConfig,
LegendApplicationConfigurationData,
LegendApplicationVersionData,
} from '../stores/LegendApplicationConfig';
} from '../stores/LegendApplicationConfig.js';
import {
type AbstractPlugin,
type AbstractPreset,
Expand All @@ -31,11 +31,11 @@ import {
assertNonNullable,
NetworkClient,
} from '@finos/legend-shared';
import { APPLICATION_EVENT } from '../stores/ApplicationEvent';
import { APPLICATION_EVENT } from '../stores/ApplicationEvent.js';
import { configureComponents } from '@finos/legend-art';
import type { GraphPluginManager } from '@finos/legend-graph';
import type { LegendApplicationPluginManager } from './LegendApplicationPluginManager';
import { setupPureLanguageService } from '../stores/PureLanguageSupport';
import type { LegendApplicationPluginManager } from './LegendApplicationPluginManager.js';
import { setupPureLanguageService } from '../stores/PureLanguageSupport.js';

export abstract class LegendApplicationLogger {
abstract debug(event: LogEvent, ...data: unknown[]): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
type TracerServicePluginManager,
AbstractPluginManager,
} from '@finos/legend-shared';
import type { LegendApplicationPlugin } from '../stores/LegendApplicationPlugin';
import type { LegendApplicationPlugin } from '../stores/LegendApplicationPlugin.js';

export class LegendApplicationPluginManager
extends AbstractPluginManager
Expand Down
Loading