Skip to content

Commit d52bae7

Browse files
authored
Fix esm import (#86)
* Fix ESM local import * Add tool to auto fix import
1 parent aeb14da commit d52bae7

29 files changed

+101
-35
lines changed

packages/components/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"deploy:docs": "yarn run build:docs && gh-pages -d storybook-static",
3434
"doc": "api-extractor run --local",
3535
"prettier:check": "prettier --config ../../.prettierrc --check \"src/**/*.ts\"",
36-
"prettier": "prettier --config ../../.prettierrc --write \"src/**/*.ts\"",
36+
"prettier": "tsc-esm-fix --src=\"src\" --ext=\".js\" && prettier --config ../../.prettierrc --write \"src/**/*.ts\"",
3737
"eslint:check": "eslint . --ext .ts",
3838
"eslint": "eslint . --ext .ts --fix",
3939
"prepublishOnly": "rimraf README.md && cp ../../README.md . && yarn run build",
@@ -91,6 +91,7 @@
9191
"storybook": "^7.5.3",
9292
"ts-jest": "^29.1.0",
9393
"ts-loader": "^9.4.3",
94+
"tsc-esm-fix": "^2.20.21",
9495
"tslib": "^2.6.0",
9596
"typescript": "~5.2.2",
9697
"webpack": "^5.0.0"

packages/components/src/accordion-item/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
AccordionItemOptions,
88
accordionItemTemplate as template
99
} from '@microsoft/fast-foundation';
10-
import { accordionItemStyles as styles } from './accordion-item.styles';
10+
import { accordionItemStyles as styles } from './accordion-item.styles.js';
1111

1212
/**
1313
* A function that returns a {@link @microsoft/fast-foundation#AccordionItem} registration for configuring the component with a DesignSystem.

packages/components/src/anchor/anchor.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
4-
import { getFaIcon } from '../utilities/storybook';
4+
import { getFaIcon } from '../utilities/storybook/index.js';
55

66
export default {
77
title: 'Components/Anchor',

packages/components/src/breadcrumb-item/breadcrumb-item.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
4-
import { getFaIcon } from '../utilities/storybook';
4+
import { getFaIcon } from '../utilities/storybook/index.js';
55

66
export default {
77
title: 'Components/Breadcrumb Item',

packages/components/src/breadcrumb/breadcrumb.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
4-
import { getFaIcon } from '../utilities/storybook';
4+
import { getFaIcon } from '../utilities/storybook/index.js';
55

66
export default {
77
title: 'Components/Breadcrumb',

packages/components/src/button/button.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
44
import { action } from '@storybook/addon-actions';
5-
import { getFaIcon } from '../utilities/storybook';
5+
import { getFaIcon } from '../utilities/storybook/index.js';
66

77
export default {
88
title: 'Components/Button',

packages/components/src/card/card.stories.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
4-
import { neutralForegroundRest, typeRampBaseFontSize } from '../design-tokens';
4+
import {
5+
neutralForegroundRest,
6+
typeRampBaseFontSize
7+
} from '../design-tokens.js';
58

69
export default {
710
title: 'Components/Card',

packages/components/src/checkbox/checkbox.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33
import type { Meta, StoryFn, StoryObj } from '@storybook/html';
44
import { action } from '@storybook/addon-actions';
5-
import { Checkbox } from './index';
5+
import { Checkbox } from './index.js';
66

77
export default {
88
title: 'Components/Checkbox',

packages/components/src/combobox/combobox.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { getFaIcon } from '../utilities/storybook';
7-
import { Combobox } from './index';
6+
import { getFaIcon } from '../utilities/storybook/index.js';
7+
import { Combobox } from './index.js';
88

99
export default {
1010
title: 'Components/Combobox',

packages/components/src/data-grid/data-grid.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
5-
import { DataGrid } from './index';
5+
import { DataGrid } from './index.js';
66

77
export default {
88
title: 'Components/Data Grid',

packages/components/src/date-field/date-field.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test('temporary test', () => {
88

99
/* TODO FIXME
1010
jupyter-ui-toolkit/node_modules/@microsoft/fast-element/dist/esm/index.js:1
11-
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from "./platform";
11+
({"Object.<anonymous>":function(module,exports,require,`${process.platform === 'win32' ? '' : '/'}${/file:\/{2,3}(.+)\/[^/]/.exec(import.meta.url)![1]}`,`${process.platform === 'win32' ? '' : '/'}${/file:\/{2,3}(.+)/.exec(import.meta.url)![1]}`,jest){export * from "./platform";
1212
1313
SyntaxError: Unexpected token 'export'
1414

packages/components/src/date-field/date-field.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { getFaIcon } from '../utilities/storybook';
7-
import { DateField } from './index';
6+
import { getFaIcon } from '../utilities/storybook/index.js';
7+
import { DateField } from './index.js';
88

99
export default {
1010
title: 'Components/Date Field',

packages/components/src/date-field/date-field.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
DelegatesARIATextbox
1616
} from '@microsoft/fast-foundation';
1717
import type { FoundationElementDefinition } from '@microsoft/fast-foundation';
18-
import { FormAssociatedDateField } from './date-field.form-associated';
19-
import { nullableDateConverter } from '../converters';
18+
import { FormAssociatedDateField } from './date-field.form-associated.js';
19+
import { nullableDateConverter } from '../converters.js';
2020

2121
/**
2222
* Number field appearances

packages/components/src/menu-item/menu-item.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
5-
import { getFaIcon } from '../utilities/storybook';
5+
import { getFaIcon } from '../utilities/storybook/index.js';
66

77
export default {
88
title: 'Components/Menu Item',

packages/components/src/menu/menu.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
5-
import { getFaIcon } from '../utilities/storybook';
5+
import { getFaIcon } from '../utilities/storybook/index.js';
66

77
export default {
88
title: 'Components/Menu',

packages/components/src/number-field/number-field.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { getFaIcon } from '../utilities/storybook';
7-
import { NumberField } from './index';
6+
import { getFaIcon } from '../utilities/storybook/index.js';
7+
import { NumberField } from './index.js';
88

99
export default {
1010
title: 'Components/Number Field',

packages/components/src/search/search.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { getFaIcon } from '../utilities/storybook';
7-
import { Search } from './index';
6+
import { getFaIcon } from '../utilities/storybook/index.js';
7+
import { Search } from './index.js';
88

99
export default {
1010
title: 'Components/Search',

packages/components/src/select/select.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { getFaIcon } from '../utilities/storybook';
6+
import { getFaIcon } from '../utilities/storybook/index.js';
77

88
export default {
99
title: 'Components/Select',

packages/components/src/styles/size.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Distributed under the terms of the Modified BSD License.
44

55
import { cssPartial } from '@microsoft/fast-element';
6-
import { baseHeightMultiplier, density, designUnit } from '../design-tokens';
6+
import { baseHeightMultiplier, density, designUnit } from '../design-tokens.js';
77

88
/**
99
* A formula to retrieve the control height.

packages/components/src/switch/switch.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { Switch } from './index';
6+
import { Switch } from './index.js';
77

88
export default {
99
title: 'Components/Switch',

packages/components/src/tab/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import { Tab, tabTemplate as template } from '@microsoft/fast-foundation';
5-
import { tabStyles as styles } from './tab.styles';
5+
import { tabStyles as styles } from './tab.styles.js';
66

77
/**
88
* A function that returns a {@link @microsoft/fast-foundation#Tab} registration for configuring the component with a DesignSystem.

packages/components/src/tabs/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
import { Tabs, tabsTemplate as template } from '@microsoft/fast-foundation';
5-
import { tabsStyles as styles } from './tabs.styles';
5+
import { tabsStyles as styles } from './tabs.styles.js';
66

77
/**
88
* A function that returns a {@link @microsoft/fast-foundation#Tabs} registration for configuring the component with a DesignSystem.

packages/components/src/text-area/text-area.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { TextArea } from './index';
6+
import { TextArea } from './index.js';
77

88
export default {
99
title: 'Components/Text Area',

packages/components/src/text-field/text-field.stories.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { getFaIcon } from '../utilities/storybook';
7-
import { TextField } from './index';
6+
import { getFaIcon } from '../utilities/storybook/index.js';
7+
import { TextField } from './index.js';
88

99
export default {
1010
title: 'Components/Text Field',

packages/components/src/toolbar/toolbar.styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
fillColor,
1818
focusStrokeWidth,
1919
strokeWidth
20-
} from '../design-tokens';
20+
} from '../design-tokens.js';
2121

2222
/**
2323
* Styles for the Toolbar

packages/components/src/tree-item/tree-item.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Jupyter Development Team.
22
// Distributed under the terms of the Modified BSD License.
33
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
4-
import { getFaIcon } from '../utilities/storybook';
4+
import { getFaIcon } from '../utilities/storybook/index.js';
55

66
export default {
77
title: 'Components/Tree Item',

packages/components/src/tree-view/tree-view.stories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import type { StoryFn, Meta, StoryObj } from '@storybook/html';
55
import { action } from '@storybook/addon-actions';
6-
import { TreeView } from './index';
6+
import { TreeView } from './index.js';
77

88
export default {
99
title: 'Components/Tree View',

packages/components/src/utilities/theme/applyTheme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
neutralColor,
2222
strokeWidth,
2323
typeRampBaseFontSize
24-
} from '../../design-tokens';
24+
} from '../../design-tokens.js';
2525

2626
const THEME_NAME_BODY_ATTRIBUTE = 'data-jp-theme-name';
2727
const THEME_MODE_BODY_ATTRIBUTE = 'data-jp-theme-light';

yarn.lock

+63-1
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,7 @@ __metadata:
24632463
storybook: ^7.5.3
24642464
ts-jest: ^29.1.0
24652465
ts-loader: ^9.4.3
2466+
tsc-esm-fix: ^2.20.21
24662467
tslib: ^2.6.0
24672468
typescript: ~5.2.2
24682469
webpack: ^5.0.0
@@ -8465,6 +8466,13 @@ __metadata:
84658466
languageName: node
84668467
linkType: hard
84678468

8469+
"depseek@npm:^0.2.1":
8470+
version: 0.2.2
8471+
resolution: "depseek@npm:0.2.2"
8472+
checksum: c8df9d748591b49276bbfa00caefe237de92cd3160af8f081d81d1cae1fe32d61c8a3d01bdcb5eae26739e7edf086792fe84812126248aec68148fe3ec9f3eef
8473+
languageName: node
8474+
linkType: hard
8475+
84688476
"dequal@npm:^2.0.0, dequal@npm:^2.0.2":
84698477
version: 2.0.3
84708478
resolution: "dequal@npm:2.0.3"
@@ -9941,6 +9949,17 @@ __metadata:
99419949
languageName: node
99429950
linkType: hard
99439951

9952+
"fs-extra@npm:^11.2.0":
9953+
version: 11.2.0
9954+
resolution: "fs-extra@npm:11.2.0"
9955+
dependencies:
9956+
graceful-fs: ^4.2.0
9957+
jsonfile: ^6.0.1
9958+
universalify: ^2.0.0
9959+
checksum: b12e42fa40ba47104202f57b8480dd098aa931c2724565e5e70779ab87605665594e76ee5fb00545f772ab9ace167fe06d2ab009c416dc8c842c5ae6df7aa7e8
9960+
languageName: node
9961+
linkType: hard
9962+
99449963
"fs-extra@npm:~7.0.1":
99459964
version: 7.0.1
99469965
resolution: "fs-extra@npm:7.0.1"
@@ -10407,6 +10426,19 @@ __metadata:
1040710426
languageName: node
1040810427
linkType: hard
1040910428

10429+
"globby@npm:^13.2.2":
10430+
version: 13.2.2
10431+
resolution: "globby@npm:13.2.2"
10432+
dependencies:
10433+
dir-glob: ^3.0.1
10434+
fast-glob: ^3.3.0
10435+
ignore: ^5.2.4
10436+
merge2: ^1.4.1
10437+
slash: ^4.0.0
10438+
checksum: f3d84ced58a901b4fcc29c846983108c426631fe47e94872868b65565495f7bee7b3defd68923bd480582771fd4bbe819217803a164a618ad76f1d22f666f41e
10439+
languageName: node
10440+
linkType: hard
10441+
1041010442
"globby@npm:^6.1.0":
1041110443
version: 6.1.0
1041210444
resolution: "globby@npm:6.1.0"
@@ -13184,6 +13216,13 @@ __metadata:
1318413216
languageName: node
1318513217
linkType: hard
1318613218

13219+
"meow@npm:^12.1.1":
13220+
version: 12.1.1
13221+
resolution: "meow@npm:12.1.1"
13222+
checksum: a6f3be85fbe53430ef53ab933dd790c39216eb4dbaabdbef593aa59efb40ecaa417897000175476bc33eed09e4cbce01df7ba53ba91e9a4bd84ec07024cb8914
13223+
languageName: node
13224+
linkType: hard
13225+
1318713226
"meow@npm:^8.1.2":
1318813227
version: 8.1.2
1318913228
resolution: "meow@npm:8.1.2"
@@ -16727,6 +16766,13 @@ __metadata:
1672716766
languageName: node
1672816767
linkType: hard
1672916768

16769+
"slash@npm:^4.0.0":
16770+
version: 4.0.0
16771+
resolution: "slash@npm:4.0.0"
16772+
checksum: da8e4af73712253acd21b7853b7e0dbba776b786e82b010a5bfc8b5051a1db38ed8aba8e1e8f400dd2c9f373be91eb1c42b66e91abb407ff42b10feece5e1d2d
16773+
languageName: node
16774+
linkType: hard
16775+
1673016776
"slice-ansi@npm:^4.0.0":
1673116777
version: 4.0.0
1673216778
resolution: "slice-ansi@npm:4.0.0"
@@ -17784,6 +17830,22 @@ __metadata:
1778417830
languageName: node
1778517831
linkType: hard
1778617832

17833+
"tsc-esm-fix@npm:^2.20.21":
17834+
version: 2.20.21
17835+
resolution: "tsc-esm-fix@npm:2.20.21"
17836+
dependencies:
17837+
depseek: ^0.2.1
17838+
fs-extra: ^11.2.0
17839+
globby: ^13.2.2
17840+
json5: ^2.2.3
17841+
meow: ^12.1.1
17842+
tslib: ^2.6.2
17843+
bin:
17844+
tsc-esm-fix: target/es6/cli.mjs
17845+
checksum: c33c88cceff7a1c5aad4c1e1f029604bfd2fa9f83e273f4710fe9e12be18cd902937a88d35065d0e9cc8ef2b9f78e59494d092bd4a36d4ee47df604ed04201cd
17846+
languageName: node
17847+
linkType: hard
17848+
1778717849
"tsconfig-paths@npm:^3.12.0":
1778817850
version: 3.12.0
1778917851
resolution: "tsconfig-paths@npm:3.12.0"
@@ -17828,7 +17890,7 @@ __metadata:
1782817890
languageName: node
1782917891
linkType: hard
1783017892

17831-
"tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.3.0, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.6.0":
17893+
"tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.3.0, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.6.0, tslib@npm:^2.6.2":
1783217894
version: 2.6.2
1783317895
resolution: "tslib@npm:2.6.2"
1783417896
checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad

0 commit comments

Comments
 (0)