Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/angular/src/lazy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export {
isPlatform,
getTimeGivenProgression,
getIonPageElement,
componentOnReady,
// TYPES
Animation,
AnimationBuilder,
Expand Down Expand Up @@ -105,6 +106,7 @@ export {
MenuCustomEvent,
ModalDragEventDetail,
NavCustomEvent,
OverlayEventDetail,
PlatformConfig,
RadioGroupCustomEvent,
RadioGroupChangeEventDetail,
Expand All @@ -116,6 +118,7 @@ export {
RangeKnobMoveEndCustomEvent,
RangeKnobName,
RangeKnobPosition,
RangeValue,
RefresherCustomEvent,
RefresherEventDetail,
RefresherPullEndCustomEvent,
Expand All @@ -138,6 +141,7 @@ export {
SegmentValue,
SelectChangeEventDetail,
SelectCustomEvent,
SelectInterface,
TabsCustomEvent,
TextareaChangeEventDetail,
TextareaCustomEvent,
Expand All @@ -149,3 +153,4 @@ export {
TransitionOptions,
openURL,
} from '@ionic/core';
export { setNonce } from '@ionic/core/loader';
5 changes: 5 additions & 0 deletions packages/angular/src/standalone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export {
getPlatforms,
isPlatform,
getTimeGivenProgression,
componentOnReady,
setNonce,
Comment on lines +55 to +56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in CI fails if one of these exports is dropped from @ionic/angular or @ionic/angular/standalone. verify-exports.js only checks the per-component entries in package.json, and the Angular test app doesn't import any of them.

The Angular docs examples will import OverlayEventDetail and the rest from here too, so please add a usage of componentOnReady, setNonce, OverlayEventDetail, RangeValue and SelectInterface to the test app, once under standalone and once under lazy. That way a removed export fails CI, the same way the Vue type-test file does.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Added the five exports to the providers pages in both lazy and standalone in e6c1615, with a spec for each. Removing any of them now fails the test app build.

} from '@ionic/core/components';
export type {
Animation,
Expand Down Expand Up @@ -97,6 +99,7 @@ export type {
MenuCustomEvent,
ModalDragEventDetail,
NavCustomEvent,
OverlayEventDetail,
PlatformConfig,
RadioGroupCustomEvent,
RadioGroupChangeEventDetail,
Expand All @@ -108,6 +111,7 @@ export type {
RangeKnobMoveEndCustomEvent,
RangeKnobName,
RangeKnobPosition,
RangeValue,
RefresherCustomEvent,
RefresherEventDetail,
RefresherPullEndCustomEvent,
Expand All @@ -130,6 +134,7 @@ export type {
SegmentValue,
SelectChangeEventDetail,
SelectCustomEvent,
SelectInterface,
TabsCustomEvent,
TextareaChangeEventDetail,
TextareaCustomEvent,
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/test/base/e2e/src/lazy/providers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ test.describe('Providers', () => {
await expect(page.locator('#resize-count')).toHaveText('2');
});

test('should export the core APIs', async ({ page }) => {
await expect(page.locator('#core-exports-loaded')).toHaveText('true');
});

test('should detect testing mode', async ({ page }) => {
await page.goto('/lazy/providers?ionic:_testing=true');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ test.describe('Providers', () => {

await expect(page.locator('#keyboard-height')).toHaveText('12345');
});

test('should export the core APIs', async ({ page }) => {
await expect(page.locator('#core-exports-loaded')).toHaveText('true');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<p>
isReady: <span id="is-ready">{{isReady}}</span>
</p>
<p>
coreExportsLoaded: <span id="core-exports-loaded">{{coreExportsLoaded}}</span>
</p>
<p>
isResumed: <span id="is-resumed">{{isResumed}}</span>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import {
NavController,
DomController,
Config,
componentOnReady,
setNonce,
} from '@ionic/angular/lazy';
import type { OverlayEventDetail, RangeValue, SelectInterface } from '@ionic/angular/lazy';

import { assertZoneContext } from '../../zone-assert.util';

Expand All @@ -33,6 +36,7 @@ export class ProvidersComponent {
keyboardHeight = 0;
queryParams = '';
registeredMenuCount = 0;
coreExportsLoaded = false;

constructor(
private actionSheetCtrl: ActionSheetController,
Expand Down Expand Up @@ -66,6 +70,21 @@ export class ProvidersComponent {
this.isLoaded = true;
}

/**
* The app fails to compile if any of these core APIs is no longer exported
* from `@ionic/angular/lazy`. `setNonce` is only checked, not called, so the
* test app does not get a nonce applied to its styles.
*/
const detail: OverlayEventDetail<string> = { data: 'saved', role: 'confirm' };
const rangeValue: RangeValue = { lower: 10, upper: 50 };
const selectInterface: SelectInterface = 'popover';
this.coreExportsLoaded =
typeof componentOnReady === 'function' &&
typeof setNonce === 'function' &&
detail.role === 'confirm' &&
typeof rangeValue === 'object' &&
selectInterface === 'popover';

// test platform ready()
platform.ready().then(() => {
assertZoneContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<ul>
<li>Keyboard Height: <span id="keyboard-height">{{ keyboardHeight }}</span></li>
<li>Core Exports Loaded: <span id="core-exports-loaded">{{ coreExportsLoaded }}</span></li>
</ul>

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Config } from '@ionic/angular';
import { Config, componentOnReady, setNonce } from '@ionic/angular';
import type { OverlayEventDetail, RangeValue, SelectInterface } from '@ionic/angular';

@Component({
selector: 'app-providers',
Expand All @@ -8,8 +9,24 @@ import { Config } from '@ionic/angular';
})
export class ProvidersComponent {
keyboardHeight?: number;
coreExportsLoaded = false;

constructor(private config: Config) {
this.keyboardHeight = config.get('keyboardHeight');

/**
* The app fails to compile if any of these core APIs is no longer exported
* from `@ionic/angular`. `setNonce` is only checked, not called, so the
* test app does not get a nonce applied to its styles.
*/
const detail: OverlayEventDetail<string> = { data: 'saved', role: 'confirm' };
const rangeValue: RangeValue = { lower: 10, upper: 50 };
const selectInterface: SelectInterface = 'popover';
this.coreExportsLoaded =
typeof componentOnReady === 'function' &&
typeof setNonce === 'function' &&
detail.role === 'confirm' &&
typeof rangeValue === 'object' &&
selectInterface === 'popover';
}
}
7 changes: 7 additions & 0 deletions packages/react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export {
IonicSlides,
getTimeGivenProgression,
getIonPageElement,
getMode,
componentOnReady,
menuController,
setNonce,
openURL,
LogLevel,

Expand Down Expand Up @@ -60,6 +64,7 @@ export {
ModalDragEventDetail,
ModalOptions,
NavCustomEvent,
OverlayEventDetail,
PopoverOptions,
RadioGroupCustomEvent,
RadioGroupChangeEventDetail,
Expand All @@ -71,6 +76,7 @@ export {
RangeKnobMoveEndCustomEvent,
RangeKnobName,
RangeKnobPosition,
RangeValue,
RefresherCustomEvent,
RefresherEventDetail,
ReorderMoveCustomEvent,
Expand All @@ -91,6 +97,7 @@ export {
SegmentValue,
SelectChangeEventDetail,
SelectCustomEvent,
SelectInterface,
TabsCustomEvent,
TextareaChangeEventDetail,
TextareaCustomEvent,
Expand Down
23 changes: 23 additions & 0 deletions packages/react/test/base/src/exports.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { componentOnReady, getMode, menuController, setNonce } from '@ionic/react';
import type { OverlayEventDetail, RangeValue, SelectInterface } from '@ionic/react';
import { describe, expect, it } from 'vitest';

describe('core exports', () => {
it('should export the core utilities', () => {
expect(getMode).toEqual(expect.any(Function));
expect(componentOnReady).toEqual(expect.any(Function));
expect(menuController.open).toEqual(expect.any(Function));
expect(setNonce).toEqual(expect.any(Function));
});

it('should export the core types', () => {
/* The app build type checks this file, so it fails if one of these types is no longer exported. */
const detail: OverlayEventDetail<string> = { data: 'saved', role: 'confirm' };
const value: RangeValue = { lower: 10, upper: 50 };
const selectInterface: SelectInterface = 'popover';

expect(detail.role).toBe('confirm');
expect(value).toEqual({ lower: 10, upper: 50 });
expect(selectInterface).toBe('popover');
});
});
2 changes: 1 addition & 1 deletion packages/vue/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
},
],
plugins: [
typescript(),
typescript({ exclude: ['**/*.type-test.ts'] }),
resolve()
],
external: (
Expand Down
3 changes: 3 additions & 0 deletions packages/vue/src/exports.type-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { OverlayEventDetail, RangeValue, SelectInterface } from "./index";

export type CoreTypeExports = [OverlayEventDetail, RangeValue, SelectInterface];
Comment on lines +1 to +3

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since rollup.config.mjs gives the TypeScript plugin the whole tsconfig, this file ends up in the published package as dist/types/exports.type-test.d.ts. Excluding it in rollup.config.mjs keeps it out of dist, and npm run typecheck still checks it:

typescript({ exclude: ['**/*.type-test.ts'] }),

The pattern resolves from rootDir (src), so src/**/*.type-test.ts doesn't match.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added your exclude in 339481b. The file is no longer in dist, and typecheck still catches a removed export.

6 changes: 6 additions & 0 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export {
menuController,
getTimeGivenProgression,
getIonPageElement,
getMode,
componentOnReady,
setNonce,
openURL,

// TYPES
Expand Down Expand Up @@ -95,6 +98,7 @@ export {
ModalDragEventDetail,
ModalOptions,
NavCustomEvent,
OverlayEventDetail,
Platforms,
PlatformConfig,
PopoverOptions,
Expand All @@ -108,6 +112,7 @@ export {
RangeKnobMoveEndCustomEvent,
RangeKnobName,
RangeKnobPosition,
RangeValue,
RefresherCustomEvent,
RefresherEventDetail,
ReorderMoveCustomEvent,
Expand All @@ -128,6 +133,7 @@ export {
SegmentValue,
SelectChangeEventDetail,
SelectCustomEvent,
SelectInterface,
TabsCustomEvent,
TextareaChangeEventDetail,
TextareaCustomEvent,
Expand Down
11 changes: 11 additions & 0 deletions packages/vue/test/base/tests/unit/exports.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, expect, it } from 'vitest';
import { componentOnReady, getMode, menuController, setNonce } from '@ionic/vue';
Comment thread
ShaneK marked this conversation as resolved.
Resolved

describe('core exports', () => {
it('should export the core utilities', () => {
expect(getMode).toEqual(expect.any(Function));
expect(componentOnReady).toEqual(expect.any(Function));
expect(menuController.open).toEqual(expect.any(Function));
expect(setNonce).toEqual(expect.any(Function));
});
});
Loading