Skip to content

Commit c50d895

Browse files
authored
feat(react): add custom elements bundle (#23896)
1 parent d1763fc commit c50d895

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+321
-565
lines changed

.circleci/config.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -377,28 +377,6 @@ jobs:
377377
command: npm run test.spec
378378
working_directory: /tmp/workspace/packages/react
379379

380-
test-react-router-spec:
381-
<<: *defaults
382-
steps:
383-
- checkout
384-
- attach_workspace:
385-
at: /tmp/workspace
386-
- run:
387-
command: sudo npm link
388-
working_directory: /tmp/workspace/core
389-
- run:
390-
command: sudo npm link @ionic/core
391-
working_directory: /tmp/workspace/packages/react
392-
- run:
393-
command: sudo npm link
394-
working_directory: /tmp/workspace/packages/react
395-
- run:
396-
command: sudo npm link @ionic/react
397-
working_directory: /tmp/workspace/packages/react-router
398-
- run:
399-
command: npm run test.spec
400-
working_directory: /tmp/workspace/packages/react-router
401-
402380
install-react-test-app:
403381
<<: *defaults
404382
steps:
@@ -537,8 +515,6 @@ workflows:
537515
requires: [build-react-router]
538516
- test-react-spec:
539517
requires: [build-react]
540-
- test-react-router-spec:
541-
requires: [build-react-router]
542518
- install-react-test-app:
543519
requires: [build-core]
544520
- test-react-e2e:

core/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@jest/core": "^26.6.3",
4141
"@rollup/plugin-node-resolve": "^8.4.0",
4242
"@rollup/plugin-virtual": "^2.0.3",
43-
"@stencil/react-output-target": "^0.0.12",
43+
"@stencil/react-output-target": "^0.1.0-2",
4444
"@stencil/sass": "1.3.2",
4545
"@stencil/vue-output-target": "^0.5.1",
4646
"@types/jest": "^26.0.20",

core/src/components/menu/menu.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ export class Menu implements ComponentInterface, MenuI {
148148
@Event() protected ionMenuChange!: EventEmitter<MenuChangeEventDetail>;
149149

150150
async connectedCallback() {
151+
// TODO: connectedCallback is fired in CE build
152+
// before WC is defined. This needs to be fixed in Stencil.
153+
if (typeof (customElements as any) !== 'undefined') {
154+
await customElements.whenDefined('ion-menu');
155+
}
156+
151157
if (this.type === undefined) {
152158
this.type = config.get('menuType', 'overlay');
153159
}

core/src/components/split-pane/split-pane.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ export class SplitPane implements ComponentInterface {
6060
this.ionSplitPaneVisible.emit(detail);
6161
}
6262

63-
connectedCallback() {
63+
async connectedCallback() {
64+
// TODO: connectedCallback is fired in CE build
65+
// before WC is defined. This needs to be fixed in Stencil.
66+
if (typeof (customElements as any) !== 'undefined') {
67+
await customElements.whenDefined('ion-split-pane');
68+
}
6469
this.styleChildren();
6570
this.updateState();
6671
}

core/stencil.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const config: Config = {
6464
outputTargets: [
6565
reactOutputTarget({
6666
componentCorePackage: '@ionic/core',
67+
includeImportCustomElements: true,
6768
includePolyfills: false,
6869
includeDefineCustomElements: false,
6970
proxiesFile: '../packages/react/src/components/proxies.ts',

packages/react-router/package.json

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"release": "np --any-branch --no-cleanup",
2727
"lint": "tslint --project .",
2828
"lint.fix": "tslint --project . --fix",
29-
"tsc": "tsc -p .",
30-
"test.spec": "jest --ci"
29+
"tsc": "tsc -p ."
3130
},
3231
"main": "dist/index.js",
3332
"module": "dist/index.esm.js",
@@ -49,16 +48,11 @@
4948
"@ionic/core": "6.0.0-beta.5",
5049
"@ionic/react": "6.0.0-beta.5",
5150
"@rollup/plugin-node-resolve": "^8.1.0",
52-
"@testing-library/jest-dom": "^5.11.6",
53-
"@testing-library/react": "^11.2.2",
54-
"@testing-library/user-event": "^12.0.11",
55-
"@types/jest": "^26.0.15",
5651
"@types/node": "^14.0.14",
5752
"@types/react": "16.14.0",
5853
"@types/react-dom": "^16.9.0",
5954
"@types/react-router": "^5.0.3",
6055
"@types/react-router-dom": "^5.1.5",
61-
"jest": "^26.6.3",
6256
"np": "^6.4.0",
6357
"prettier": "^2.2.0",
6458
"react": "^16.9.0",
@@ -68,33 +62,9 @@
6862
"rimraf": "^3.0.2",
6963
"rollup": "^2.26.4",
7064
"rollup-plugin-sourcemaps": "^0.6.2",
71-
"ts-jest": "^26.4.4",
7265
"tslint": "^6.1.2",
7366
"tslint-ionic-rules": "0.0.21",
7467
"tslint-react": "^5.0.0",
7568
"typescript": "^3.9.5"
76-
},
77-
"jest": {
78-
"preset": "ts-jest",
79-
"setupFilesAfterEnv": [
80-
"<rootDir>/setupTests.ts"
81-
],
82-
"testPathIgnorePatterns": [
83-
"node_modules",
84-
"dist-transpiled",
85-
"dist",
86-
"<rootDir>/test-app"
87-
],
88-
"globals": {
89-
"ts-jest": {
90-
"diagnostics": false
91-
}
92-
},
93-
"modulePaths": [
94-
"<rootDir>"
95-
],
96-
"moduleNameMapper": {
97-
"\\.(css|jpg|png|svg)$": "<rootDir>/empty-module.js"
98-
}
9969
}
10070
}

packages/react-router/setupTests.ts

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

packages/react-router/src/__tests__/Router.spec.tsx

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

packages/react-router/test-app/package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-router/test-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"@capacitor/ios": "^2.2.0",
1010
"@ionic/react": "5.6.3",
1111
"@ionic/react-router": "^5.6.3",
12+
"@stencil/core": "^2.8.0",
1213
"@svgr/webpack": "4.3.3",
1314
"@testing-library/jest-dom": "^4.2.4",
1415
"@testing-library/react": "^9.4.0",
@@ -72,7 +73,7 @@
7273
"style-loader": "0.23.1",
7374
"terser-webpack-plugin": "2.3.4",
7475
"ts-pnp": "1.1.5",
75-
"typescript": "^3.9.5",
76+
"typescript": "^4.4.2",
7677
"url-loader": "2.3.0",
7778
"wait-on": "^5.3.0",
7879
"webpack": "4.41.5",

packages/react-router/test-app/scripts/sync.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ rm -rf node_modules/@ionic/react-router/dist
99
cp -a ../dist node_modules/@ionic/react-router/dist
1010
cp -a ../package.json node_modules/@ionic/react-router/package.json
1111

12-
# Copy core dist
13-
rm -rf node_modules/@ionic/core/dist node_modules/@ionic/core/loader
14-
cp -a ../../../core/dist node_modules/@ionic/core/dist
15-
cp -a ../../../core/loader node_modules/@ionic/core/loader
12+
# Copy core dist and components
13+
rm -rf node_modules/@ionic/core/dist node_modules/@ionic/core/components
1614
cp -a ../../../core/package.json node_modules/@ionic/core/package.json
15+
cp -a ../../../core/dist node_modules/@ionic/core/dist
16+
cp -a ../../../core/components node_modules/@ionic/core/components
1717

1818
# Copy ionicons
1919
rm -rf node_modules/ionicons

packages/react-router/test-app/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import Refs from './pages/refs/Refs';
3636
import DynamicIonpageClassnames from './pages/dynamic-ionpage-classnames/DynamicIonpageClassnames';
3737
import Tabs from './pages/tabs/Tabs';
3838
import TabsSecondary from './pages/tabs/TabsSecondary';
39-
debugger;
4039
const App: React.FC = () => {
4140
return (
4241
<IonApp>

packages/react/src/components/CreateAnimation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
AnimationKeyFrames,
77
AnimationLifecycle,
88
createAnimation,
9-
} from '@ionic/core';
9+
} from '@ionic/core/components';
1010
import React from 'react';
1111

1212
interface PartialPropertyValue {

packages/react/src/components/IonActionSheet.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
ActionSheetButton as ActionSheetButtonCore,
33
ActionSheetOptions as ActionSheetOptionsCore,
44
actionSheetController as actionSheetControllerCore,
5-
} from '@ionic/core';
5+
} from '@ionic/core/components';
6+
import { IonActionSheet as IonActionSheetCmp } from '@ionic/core/components/ion-action-sheet.js';
67

78
import { createOverlayComponent } from './createOverlayComponent';
89

@@ -29,4 +30,4 @@ const actionSheetController = {
2930
export const IonActionSheet = /*@__PURE__*/ createOverlayComponent<
3031
ActionSheetOptions,
3132
HTMLIonActionSheetElement
32-
>('IonActionSheet', actionSheetController);
33+
>('ion-action-sheet', actionSheetController, IonActionSheetCmp);

0 commit comments

Comments
 (0)