Skip to content

Fix: Adjust stub file paths for accurate resolution during rolldown build #2217

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

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

babu-ch
Copy link
Contributor

@babu-ch babu-ch commented Jun 24, 2025

Fixed a bug that caused stub generation to not work properly.

$ nr build:rolldown  
$ ls -1 packages/*/dist/*js > before_build
$ git checkout rolldown
$ nr build:rolldown  
$ ls -1 packages/*/dist/*js > after_build
$ diff before_build after_build
2a3
> packages/core-base/dist/core-base.esm-bundler.js
7a9
> packages/core/dist/core.esm-bundler.js
13a16
> packages/core/dist/core.runtime.esm-bundler.js
17a21
> packages/devtools-types/dist/devtools-types.esm-bundler.js
20a25
> packages/message-compiler/dist/message-compiler.esm-bundler.js
26a32
> packages/petite-vue-i18n/dist/petite-vue-i18n.esm-bundler.js
32a39
> packages/petite-vue-i18n/dist/petite-vue-i18n.runtime.esm-bundler.js
38a46
> packages/shared/dist/shared.esm-bundler.js
41a50
> packages/vue-i18n-core/dist/petite-vue-i18n-core.esm-bundler.js
46a56
> packages/vue-i18n-core/dist/vue-i18n-core.esm-bundler.js
51a62
> packages/vue-i18n/dist/vue-i18n.esm-bundler.js
57a69
> packages/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js

Summary by CodeRabbit

  • Bug Fixes
    • Improved the handling and placement of generated stub files to ensure they are written to the correct location with consistent path resolution.
    • Added a console log to display the full path of each created stub file for better visibility during the build process.

@kazupon kazupon added the Type: Bug Bug or Bug fixes label Jun 24, 2025
Copy link

coderabbitai bot commented Jun 24, 2025

Walkthrough

The update revises the stub file generation logic in the write-stub plugin's writeBundle hook within the createConfig function. The stub lookup now uses the base filename and a consistent dist/ path, and the stub file is written to a resolved path under the target package's dist directory. A console log reports the stub file's creation.

Changes

File(s) Change Summary
scripts/rolldown.ts Updated stub file path resolution and writing logic in the write-stub plugin's writeBundle hook

Poem

In the warren where stubs are spun,
Paths now align, the work is done.
With bundles neat and logs that cheer,
Our code hops forward, never fear!
🎉🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

Copy link

Size Report

Bundles

File Size Gzip Brotli
core.esm-browser.prod.js 38.05 kB 11.62 kB 10.39 kB
core.global.prod.js 31.11 kB 10.78 kB 9.67 kB
core.runtime.esm-browser.prod.js 23.77 kB 7.71 kB 6.90 kB
core.runtime.global.prod.js 18.08 kB 7.04 kB 6.32 kB
message-compiler.esm-browser.prod.js 19.29 kB 5.76 kB 5.14 kB
message-compiler.global.prod.js 17.32 kB 5.55 kB 4.98 kB
petite-vue-i18n-core.esm-browser.prod.js 20.70 kB 6.98 kB 6.27 kB
petite-vue-i18n-core.global.prod.js 15.66 kB 6.08 kB 5.51 kB
petite-vue-i18n.esm-browser.prod.js 37.01 kB 11.36 kB 10.19 kB
petite-vue-i18n.global.prod.js 29.87 kB 10.21 kB 9.22 kB
petite-vue-i18n.runtime.esm-browser.prod.js 22.58 kB 7.35 kB 6.64 kB
petite-vue-i18n.runtime.global.prod.js 16.86 kB 6.42 kB 5.82 kB
vue-i18n.esm-browser.prod.js 50.71 kB 15.17 kB 13.56 kB
vue-i18n.global.prod.js 40.57 kB 13.63 kB 12.25 kB
vue-i18n.runtime.esm-browser.prod.js 36.28 kB 11.17 kB 10.03 kB
vue-i18n.runtime.global.prod.js 27.56 kB 9.88 kB 8.91 kB

Usages

Name Size Gzip Brotli
packages/size-check-core (@intlify/core) 9.22 kB 3.82 kB 3.46 kB
packages/size-check-petite-vue-i18n (petite-vue-i18n) 78.02 kB 30.40 kB 27.36 kB
packages/size-check-vue-i18n (vue-i18n) 83.24 kB 31.90 kB 28.70 kB

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6189db2 and f605e5d.

📒 Files selected for processing (1)
  • scripts/rolldown.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: E2E test for rolldown build (ubuntu-latest, 20)
  • GitHub Check: E2E test for rolldown build (macos-latest, 20)
  • GitHub Check: E2E test for rolldown build (macos-latest, 22)
  • GitHub Check: E2E test for rolldown build (windows-latest, 20)
  • GitHub Check: E2E test for rolldown build (ubuntu-latest, 22)
  • GitHub Check: release
  • GitHub Check: upload
  • GitHub Check: Build (ubuntu-latest, 20)
  • GitHub Check: Build (macos-latest, 20)
  • GitHub Check: Build (windows-latest, 20)
🔇 Additional comments (1)
scripts/rolldown.ts (1)

326-327: LGTM! Stub lookup logic correctly fixed.

The change correctly addresses the core issue by extracting the base filename and using the proper key format (dist/${filename}) to match the stubs object structure created by resolveStubs().

Comment on lines +334 to +341
const fullpath = path.join(
'packages',
target,
'dist',
path.basename(stub)
)
await fs.writeFile(fullpath, contents)
console.log(`created stub ${pc.bold(fullpath)}`)
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using absolute path resolution for better reliability.

The path construction uses relative paths which could fail if the script is executed from a different working directory. Since packagesDir is already defined (line 18), consider using it for more robust path resolution.

-            const fullpath = path.join(
-              'packages',
-              target,
-              'dist',
-              path.basename(stub)
-            )
+            const fullpath = path.join(
+              packagesDir,
+              target,
+              'dist',
+              path.basename(stub)
+            )

This ensures the stub files are written to the correct location regardless of the current working directory.

📝 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
const fullpath = path.join(
'packages',
target,
'dist',
path.basename(stub)
)
await fs.writeFile(fullpath, contents)
console.log(`created stub ${pc.bold(fullpath)}`)
const fullpath = path.join(
packagesDir,
target,
'dist',
path.basename(stub)
)
await fs.writeFile(fullpath, contents)
console.log(`created stub ${pc.bold(fullpath)}`)
🤖 Prompt for AI Agents
In scripts/rolldown.ts around lines 334 to 341, the code constructs file paths
using relative paths which may cause issues if the script runs from different
working directories. To fix this, replace the relative path construction with an
absolute path by using the already defined packagesDir variable (from line 18)
as the base directory. Join packagesDir with target, 'dist', and the stub
basename to form the fullpath, ensuring the stub files are always written to the
correct location regardless of the current working directory.

Copy link

pkg-pr-new bot commented Jun 24, 2025

Open in StackBlitz

@intlify/core

npm i https://pkg.pr.new/@intlify/core@2217

@intlify/core-base

npm i https://pkg.pr.new/@intlify/core-base@2217

@intlify/devtools-types

npm i https://pkg.pr.new/@intlify/devtools-types@2217

@intlify/message-compiler

npm i https://pkg.pr.new/@intlify/message-compiler@2217

petite-vue-i18n

npm i https://pkg.pr.new/petite-vue-i18n@2217

@intlify/shared

npm i https://pkg.pr.new/@intlify/shared@2217

vue-i18n

npm i https://pkg.pr.new/vue-i18n@2217

@intlify/vue-i18n-core

npm i https://pkg.pr.new/@intlify/vue-i18n-core@2217

commit: f605e5d

@kazupon
Copy link
Member

kazupon commented Jun 24, 2025

Thank you!

@kazupon kazupon merged commit b7c93ac into intlify:master Jun 24, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug or Bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants