-
Notifications
You must be signed in to change notification settings - Fork 13.3k
chore(angular): test schematics and code-splitting #31401
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
Open
OS-jacobbell
wants to merge
16
commits into
main
Choose a base branch
from
FW-7692
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
466de9b
chore(angular): test schematics for ng add
OS-jacobbell d2052cb
add code split test project
OS-jacobbell 0ef4de4
add code-split test automation
OS-jacobbell 5b1ac7f
remove unused svg and update ci test name
OS-jacobbell 4c31a83
move angular package tests to ci build-angular step
OS-jacobbell d4d9df9
make standalone type exports explicit
OS-jacobbell 0ec8487
apply feedback
OS-jacobbell 1f03469
download core archive in test-angular-package action
OS-jacobbell 828ab0b
apply feedback on test scripts
OS-jacobbell d0a13aa
export IonModalToken from dedicated file
OS-jacobbell 1570284
remove unused testing infrastructure from the code-split test app
OS-jacobbell 23f56fe
gitignore code-split-build directory
OS-jacobbell e5206fb
remove migration script
OS-jacobbell 9852c96
fix ci test name
OS-jacobbell fdcac9e
use repo's core in verify-schematics
OS-jacobbell b51a105
update documentation
OS-jacobbell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: 'Test Ionic Angular Package' | ||
| description: 'Test Ionic Angular Package' | ||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version: 24.x | ||
| - uses: ./.github/workflows/actions/download-archive | ||
| with: | ||
| name: ionic-core | ||
| path: ./core | ||
| filename: CoreBuild.zip | ||
| - uses: ./.github/workflows/actions/download-archive | ||
| with: | ||
| name: ionic-angular | ||
| path: ./packages/angular | ||
| filename: AngularBuild.zip | ||
| - name: 🕸️ Install Angular Dependencies | ||
| run: npm ci | ||
| shell: bash | ||
| working-directory: ./packages/angular | ||
| - name: 📐 Run Angular Package Tests | ||
| run: npm run test | ||
| shell: bash | ||
| working-directory: ./packages/angular | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /** | ||
| * Validates that per-component imports let a bundler code-split Ionic components. | ||
| * Inspects `www/stats.json`, the esbuild metafile, to see which output chunk a | ||
| * component landed in. `ion-toggle` is used by only the home page, so it | ||
| * should not be bundled with the landing page. | ||
| * | ||
| * Build core and the angular package before running this test. | ||
| */ | ||
|
|
||
| const fs = require('fs-extra'); | ||
| const path = require('path'); | ||
| const { execSync } = require('node:child_process'); | ||
|
|
||
| const PROJECT_DIR = path.join(__dirname, '../test/code-split'); | ||
| const STATS_FILE = path.join(PROJECT_DIR, 'www/stats.json'); | ||
|
|
||
|
|
||
| function collectChunks(stats, startChunkName, chunkSet) | ||
| { | ||
| chunkSet.add(startChunkName); | ||
| const chunk = stats.outputs[startChunkName] | ||
| for (const imported of chunk.imports) { | ||
| if (imported.kind === "import-statement" && !chunkSet.has(imported.path)) { | ||
| collectChunks(stats, imported.path, chunkSet); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function findChunksForPage(stats, page) { | ||
| const chunkSet = new Set(); | ||
|
|
||
| for (const [chunkName, chunkData] of Object.entries(stats.outputs || {})) { | ||
| if (chunkName.endsWith('.js')) { | ||
| const importFound = Object.keys(chunkData.inputs).some(input => input.endsWith(page)); | ||
| if (importFound) { | ||
| collectChunks(stats, chunkName, chunkSet); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return chunkSet; | ||
| } | ||
|
|
||
| function hasComponentAsInput(stats, chunks, component) { | ||
| for (const chunk of chunks) { | ||
| for (const inputName of Object.keys(stats.outputs[chunk].inputs)) { | ||
| if (inputName.endsWith(component)) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| function main() { | ||
| try { | ||
| execSync('npm i', { cwd: PROJECT_DIR }); | ||
| execSync('./sync.sh', { cwd: PROJECT_DIR }); | ||
| execSync(`npm run build`, { cwd: PROJECT_DIR, stdio: 'inherit' }); | ||
|
|
||
| const stats = fs.readJsonSync(STATS_FILE); | ||
| const chunks = findChunksForPage(stats, 'landing.page.ts'); | ||
|
|
||
| const splitComponent = 'ion-toggle.js'; | ||
| if (hasComponentAsInput(stats, chunks, splitComponent)) { | ||
| throw new Error(`${splitComponent} was not split from landing page.`); | ||
| } | ||
|
|
||
| console.log('✅ verified code-split'); | ||
| } catch (error) { | ||
| process.exitCode = 1; | ||
| console.error(error); | ||
| } | ||
| } | ||
|
|
||
| main(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| const fs = require('fs-extra'); | ||
| const path = require('path'); | ||
| const { execSync } = require('node:child_process'); | ||
|
|
||
| const testName = 'schematics-test'; | ||
| const packageRootDir = path.join(__dirname, '..'); | ||
| const testDir = path.join(packageRootDir, testName); | ||
|
|
||
| try { | ||
| // Delete old packages | ||
| execSync(`rm -f *.tgz`, {cwd: packageRootDir}); | ||
|
|
||
| // Pack ionic-core | ||
| execSync(`npm pack ../../core`, {cwd: packageRootDir}); | ||
|
|
||
| // Pack ionic-angular | ||
| execSync(`npm pack`, {cwd: packageRootDir}); | ||
|
|
||
| // Create new Angular project | ||
| execSync(`npx ng new ${testName} --style css --ssr false --ai-config none`, {cwd: packageRootDir}); | ||
|
|
||
| // Install ionic-angular and core packages | ||
| execSync(`npx ng add --skip-confirmation ../ionic-angular-*`, {cwd: testDir}); | ||
|
OS-jacobbell marked this conversation as resolved.
|
||
| execSync(`npm install ../*.tgz --no-save`, {cwd: testDir}); | ||
|
|
||
| // Run build | ||
| execSync(`npm run build`, {cwd: testDir}); | ||
| } catch(error) { | ||
| console.log(error); | ||
| process.exitCode = 1; | ||
| } | ||
|
|
||
| fs.removeSync(testDir); | ||
| execSync(`rm -f *.tgz`, {cwd: packageRootDir}); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { IonModalToken } from '@ionic/angular/common'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| # Angular E2E Test Apps | ||
|
|
||
| Refer to the [Angular Testing documentation](/docs/angular/testing.md) in order to build and run the test app. | ||
|
|
||
| # Code Split Test App | ||
|
|
||
| Refer to the "Testing Code Splitting" section in the [Angular Package README](/packages/angular/README.md). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. | ||
| # For additional information regarding the format and rule options, please see: | ||
| # https://github.com/browserslist/browserslist#queries | ||
|
|
||
| # For the full list of supported browsers by the Angular framework, please see: | ||
| # https://angular.dev/reference/versions#browser-support | ||
|
|
||
| # You can see what browsers were selected by your queries by running: | ||
| # npx browserslist | ||
|
|
||
| Chrome >=107 | ||
| Firefox >=106 | ||
| Edge >=107 | ||
| Safari >=16.1 | ||
| iOS >=16.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Editor configuration, see https://editorconfig.org | ||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| indent_style = space | ||
| indent_size = 2 | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
|
|
||
| [*.ts] | ||
| quote_type = single | ||
|
|
||
| [*.md] | ||
| max_line_length = off | ||
| trim_trailing_whitespace = false |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.