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

feat: go through the mobile packaging build and release process and fix the bugs found during the build and release #2780

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

zzcr
Copy link
Member

@zzcr zzcr commented Jan 11, 2025

走通mobile打包构建发布流程,修复构建发布中发现的bug

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Release Notes

  • Type Imports

    • Updated type imports for various mobile components to use local module references
    • Affected components: Form, Tab Item, Tag, Toast
  • Package Configuration

    • Updated package version to 1.0.0-alpha.4
    • Added publish configuration and files declaration
    • Introduced new publishing script
  • Build Configuration

    • Added new Vite plugins for build process
    • Implemented string replacement for file extensions
  • Utilities

    • Removed version constant from utility modules

…ix the bugs found during the build and release
Copy link

coderabbitai bot commented Jan 11, 2025

Walkthrough

This pull request involves modifications across several files in the mobile package. The primary changes include updating type import statements in various Vue components to use local imports instead of imports from the renderless package. Additionally, the package.json file has been updated with a new version, publish configuration, and a new dependency. The utility files have seen the removal of version-related exports, and the Vite configuration has been enhanced with new plugins for build processing.

Changes

File Change Summary
packages/mobile/components/*/src/mobile.vue Updated type imports from renderless package to local files for IFormApi, ITabItemApi, ITagApi, IToastApi
packages/mobile/package.json - Version changed to "1.0.0-alpha.4"
- Added publish configuration
- Added "files" array
- Added "pub" script
- Added @rollup/plugin-replace dependency
packages/mobile/utils/index.ts Removed export of version constant
packages/mobile/utils/runtime.ts Removed version constant and its export
packages/mobile/vite.config.ts Added vite-plugin-dts and @rollup/plugin-replace plugins

Possibly related PRs

Suggested labels

chore, bug

Suggested reviewers

  • gimmyhehe
  • kagol

Poem

🐰 A rabbit's tale of code's new trail,
Imports now local, types set sail
Version trimmed, config refined
Mobile package, redesigned and aligned
Hop-hop hooray for cleaner code today! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Jan 11, 2025
Copy link

Walkthrough

This pull request addresses the mobile packaging build and release process by fixing bugs encountered during these processes. The changes involve updating import paths for type definitions, removing unused variables, and enhancing the build configuration with new plugins.

Changes

Files Summary
packages/mobile/components/form/src/mobile.vue, packages/mobile/components/tab-item/src/mobile.vue, packages/mobile/components/tag/src/mobile.vue, packages/mobile/components/toast/src/mobile.vue Updated import paths for type definitions from external to local files.
packages/mobile/package.json Added and removed dependencies.
packages/mobile/utils/index.ts, packages/mobile/utils/runtime.ts Removed unused version variable.
packages/mobile/vite.config.ts Added new plugins for build configuration.

@@ -262,8 +262,6 @@ export const CASCADER = {
MenuConnector: 'cascader-menu-'
}

export const version = process.env.RUNTIME_VERSION

export const log = (data, type = 'log') => {

Choose a reason for hiding this comment

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

The removal of version might affect parts of the codebase that rely on this variable. Ensure that this change does not break any functionality.

@@ -41,8 +41,6 @@ import validate from './validate'
import memorize from './deps/memorize'
import * as common from '.'

const version = process.env.RUNTIME_VERSION

const Renderless = {

Choose a reason for hiding this comment

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

The removal of version might affect parts of the codebase that rely on this variable. Ensure that this change does not break any functionality.

Copy link

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

@zzcr zzcr changed the title feat: go through the mobile packaging build and release process and f… feat: go through the mobile packaging build and release process and fix the bugs found during the build and release Jan 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (6)
packages/mobile/utils/runtime.ts (3)

Line range hint 15-18: Consider translating Chinese comments to English for better maintainability.

The comment block explains that these are common methods exposed to users at runtime, and dependencies should be imported using package paths. Consider translating it to English to maintain consistency and improve accessibility for non-Chinese speakers.

-/*
- * 以下是能对外抛出给用户使用的通用方法(运行时用)
- * 涉及以下的依赖统一使用包名路径的形式引入
- * 导出对象命名规范:以文件名称的驼峰格式
- */
+/*
+ * The following are common methods exposed to users (for runtime use)
+ * All dependencies should be imported using package paths
+ * Export object naming convention: camelCase format of the filename
+ */

Line range hint 42-43: Consider removing or updating the TINY_NO_NEED comment.

The comment indicates that the vue-popup package is only used internally by dialog-box. Consider:

  1. Moving this internal dependency to the dialog-box component if it's truly only used there
  2. Documenting why it needs to be in the shared utils if it must remain
-/** TINY_NO_NEED  这个包只是dialog-box 自己使用的一个中间包,暴露给用户,用户也不会使用它呀 */
+/** 
+ * Internal dependency used by dialog-box component.
+ * @internal
+ */

Line range hint 19-41: Consider organizing imports into logical groups.

While the imports are somewhat grouped, they could be better organized for improved readability and maintainability. Consider grouping them into:

  1. Core utilities
  2. DOM-related utilities
  3. Vue-specific utilities
+// Core utilities
 import * as array from './array'
 import browser from './browser'
 import * as date from './date'
 import * as decimal from './decimal'
 import * as object from './object'
 import * as string from './string'
 import * as type from './type'
 import * as dataset from './dataset'
+
+// DOM-related utilities
 import afterLeave from './deps/after-leave'
 import clickoutside from './deps/clickoutside'
 import debounce from './deps/debounce'
 import * as dom from './deps/dom'
-import popper from './deps/popper'
-import popupManager from './deps/popup-manager'
 import * as resizeEvent from './deps/resize-event'
 import * as scrollbarWidth from './deps/scrollbar-width'
 import throttle from './deps/throttle'
+
+// Vue-specific utilities
+import popper from './deps/popper'
+import popupManager from './deps/popup-manager'
 import vueEmitter from './deps/vue-emitter'
 import vuePopper from './deps/vue-popper'
 import vuePopup from './deps/vue-popup'
packages/mobile/vite.config.ts (1)

12-12: Configure DTS plugin options

The DTS plugin would benefit from explicit configuration options for better TypeScript declaration file generation.

-   dts(),
+   dts({
+     outDir: 'dist/types',
+     skipDiagnostics: false,
+     logDiagnostics: true
+   }),
packages/mobile/package.json (1)

28-30: Consider expanding the files array

The files array should include other essential files like README, LICENSE, and changelog.

  "files": [
-   "dist"
+   "dist",
+   "README.md",
+   "LICENSE",
+   "CHANGELOG.md"
  ],
packages/mobile/components/tab-item/src/mobile.vue (1)

29-29: Overall Pattern: Localizing Type Imports

The consistent pattern across all components of moving type imports from @opentiny/vue-renderless/types/* to local files aligns well with the PR's objective of fixing mobile packaging build issues. This change:

  1. Reduces external dependencies
  2. Simplifies the build process
  3. Improves maintainability
  4. Follows the existing pattern of local prop imports

Consider documenting this architectural decision to maintain consistency for future component additions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 478c7e3 and 7b009ef.

📒 Files selected for processing (8)
  • packages/mobile/components/form/src/mobile.vue (1 hunks)
  • packages/mobile/components/tab-item/src/mobile.vue (1 hunks)
  • packages/mobile/components/tag/src/mobile.vue (1 hunks)
  • packages/mobile/components/toast/src/mobile.vue (1 hunks)
  • packages/mobile/package.json (3 hunks)
  • packages/mobile/utils/index.ts (0 hunks)
  • packages/mobile/utils/runtime.ts (2 hunks)
  • packages/mobile/vite.config.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/mobile/utils/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR Unit Test
🔇 Additional comments (5)
packages/mobile/utils/runtime.ts (1)

67-67: Verify version information management after removal.

The removal of the version constant suggests that version information might be managed differently now. Please ensure that:

  1. Version information is properly managed elsewhere in the codebase
  2. Any features depending on this version constant have been updated
  3. Documentation reflects the new way of accessing version information

Let's verify the version management changes:

Also applies to: 95-95

✅ Verification successful

Version constant removal verified as safe

The version information is properly managed through package.json files and component-level version imports. No dependencies on the removed version constant were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for version-related changes in the codebase
echo "Searching for version-related files and imports..."

# Look for version management in package.json
echo "Checking package.json files:"
fd package.json | xargs rg "version"

# Look for version imports/usage
echo "Checking version imports and usage:"
rg -g '!package.json' -g '!package-lock.json' "RUNTIME_VERSION|version" 

# Look for version-related configuration
echo "Checking version configuration:"
fd "vite.config|vue.config" | xargs rg "version"

Length of output: 66464

packages/mobile/components/toast/src/mobile.vue (1)

18-18: LGTM! Verify local type definition.

The change to use a local import for IToastApi is consistent with the build process improvements.

✅ Verification successful

Type definitions verified successfully

The local import of IToastApi is properly supported with complete type definitions in toast.ts.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify IToastApi type exists in local file
ast-grep --pattern 'export interface IToastApi {
  $$$
}' packages/mobile/components/toast/src/toast.ts

Length of output: 391


Script:

#!/bin/bash
# Verify IToastState type exists
ast-grep --pattern 'export interface IToastState {
  $$$
}' packages/mobile/components/toast/src/toast.ts

Length of output: 438

packages/mobile/components/tag/src/mobile.vue (1)

26-26: LGTM! Verify local type definition.

The change to use a local import for ITagApi is consistent with the build process improvements.

✅ Verification successful

✓ Local type definitions verified

The ITagApi interface and its dependency ITagState are properly defined in the local file with all necessary type definitions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify ITagApi type exists in local file
ast-grep --pattern 'export interface ITagApi {
  $$$
}' packages/mobile/components/tag/src/tag.ts

Length of output: 448


Script:

#!/bin/bash
# Verify ITagState type exists and is properly defined
ast-grep --pattern 'interface ITagState {
  $$$
}' packages/mobile/components/tag/src/tag.ts

Length of output: 668

packages/mobile/components/form/src/mobile.vue (1)

29-29: LGTM! Verify local type definition.

The change to use a local import for IFormApi is consistent with the build process improvements.

✅ Verification successful

✓ Local type definition verified

The IFormApi interface is properly defined in the local form.ts file with all necessary form-related types and methods.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify IFormApi type exists in local file
ast-grep --pattern 'export interface IFormApi {
  $$$
}' packages/mobile/components/form/src/form.ts

Length of output: 2040

packages/mobile/components/tab-item/src/mobile.vue (1)

29-29: LGTM! Verify local type definition.

The change to use a local import for ITabItemApi is consistent with the build process improvements.

✅ Verification successful

Type definition verified successfully

The ITabItemApi interface is properly defined in the local tab-item.ts file with all required properties.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify ITabItemApi type exists in local file
ast-grep --pattern 'export interface ITabItemApi {
  $$$
}' packages/mobile/components/tab-item/src/tab-item.ts

Length of output: 766

Comment on lines +13 to +15
replace({
'.less': '.css'
})
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add preventAssignment option to replace plugin configuration

The replace plugin configuration should include preventAssignment: true and use string values for replacements to avoid potential build issues.

    replace({
-     '.less': '.css'
+     preventAssignment: true,
+     '.less': '.css',
    })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
replace({
'.less': '.css'
})
replace({
preventAssignment: true,
'.less': '.css',
})

Comment on lines +25 to +27
"publishConfig": {
"main": "dist/index.js"
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Resolve inconsistent main field declarations

There's a conflict between:

  • publishConfig.main: "dist/index.js"
  • main: "index.ts"

This could cause module resolution issues for consumers.

  "publishConfig": {
    "main": "dist/index.js"
  },
+ "main": "dist/index.js",
+ "module": "dist/index.js",
+ "types": "dist/types/index.d.ts",
- "main": "index.ts",

Also applies to: 31-31

"main": "index.ts",
"scripts": {
"build": "vite build"
"build": "vite build",
"pub": "pnpm publish --no-git-checks --access=public"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Reconsider using --no-git-checks in publish script

The --no-git-checks flag bypasses important safety checks and could lead to publishing uncommitted or untagged changes.

-   "pub": "pnpm publish --no-git-checks --access=public"
+   "pub": "pnpm publish --access=public"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"pub": "pnpm publish --no-git-checks --access=public"
"pub": "pnpm publish --access=public"

@@ -1,7 +1,7 @@
{
"name": "@opentiny/vue-mobile",
"type": "module",
"version": "3.21.0",
"version": "1.0.0-alpha.4",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Version downgrade creates dependency version mismatch

The version change to 1.0.0-alpha.4 creates a mismatch with your dependencies that use ~3.21.0:

  • @opentiny/vue-icon
  • @opentiny/vue-locale
  • @opentiny/vue-theme-mobile

Consider either:

  1. Updating these dependencies to match the new versioning scheme, or
  2. Maintaining the current 3.x version line if backward compatibility is needed
🔗 Analysis chain

Version downgrade requires careful consideration

Changing version from 3.21.0 to 1.0.0-alpha.4 is a major breaking change that requires:

  1. Clear communication to users
  2. Migration guide
  3. Changelog updates

Let's verify the impact:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for dependents that might be affected
npm info "@opentiny/vue-mobile" dependencies

Length of output: 250


Script:

#!/bin/bash
# Search for dependencies on @opentiny/vue-mobile in package.json files
rg -l "@opentiny/vue-mobile" -g "package.json"

# Check for potential TypeScript references
fd "\.d\.ts$" | xargs rg -l "@opentiny/vue-mobile"

Length of output: 152


Script:

#!/bin/bash
# Check how examples/sites depends on @opentiny/vue-mobile
cat examples/sites/package.json | grep -A 1 -B 1 "vue-mobile"

Length of output: 206

@kagol kagol merged commit c8501bf into dev Jan 11, 2025
16 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants