Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: format output structure#162

Merged
timerring merged 1 commit intomainfrom
dev
Feb 7, 2026
Merged

refactor: format output structure#162
timerring merged 1 commit intomainfrom
dev

Conversation

@timerring
Copy link
Member

Summary / 概述

This PR refactors the build output directory structure by renaming dist/src/ to dist/bundles/ to better reflect the actual content (compiled bundles vs source code) and follow modern web development conventions.

Related Issue / 关联 Issue

Close #161

Type of Change / 更改类型

  • Bug fix / 修复 Bug (non-breaking change that fixes an issue / 修复问题的非破坏性更改)
  • New feature / 新功能 (non-breaking change that adds functionality / 添加功能的非破坏性更改)
  • Breaking change / 破坏性更改 (fix or feature that would cause existing functionality to not work as expected / 会导致现有功能无法正常工作的修复或功能)
  • Documentation update / 文档更新
  • Performance improvement / 性能优化
  • Code refactoring / 代码重构
  • Other / 其他 (please describe / 请描述):

Changes Made / 更改内容

  • Updated vite.config.js to output bundles to bundles/ instead of src/
  • Modified manifest.json to reference scripts from bundles/ directory
  • Updated cli.ts build script to copy platform files to bundles/platforms/
  • Changed content.js to load inject script from bundles/inject.js

Implementation Details / 实现细节

Key Changes / 主要更改:

  1. vite.config.js - Changed Rollup output configuration:

    • entryFileNames: 'src/[name].js''bundles/[name].js'
    • chunkFileNames: 'src/chunks/[name].js''bundles/chunks/[name].js'
  2. manifest.json - Updated all script references:

    • Background service worker: src/background.jsbundles/background.js
    • Content script: src/content.jsbundles/content.js
    • Web accessible resources: src/inject.jsbundles/inject.js
    • Platform scripts: src/platforms/*.jsbundles/platforms/*.js
  3. scripts/cli.ts - Updated copy target for platform scripts:

    • Destination: dist/src/platformsdist/bundles/platforms
  4. src/content.js - Updated runtime URL for inject script:

    • chrome.runtime.getURL('src/inject.js')chrome.runtime.getURL('bundles/inject.js')

Technical Notes / 技术说明:

  • This is a structural refactoring that improves code organization and maintainability
  • The term "bundles" more accurately describes compiled/transpiled output vs "src" which implies source code
  • Follows industry best practices used by Webpack, Rollup, and Parcel
  • No changes to actual functionality - purely organizational improvement
  • Output structure now: dist/bundles/ for JavaScript bundles, dist/assets/ for static assets

Testing / 测试

Testing Checklist / 测试清单

  • I have tested this code locally / 我已在本地测试此代码
  • All existing tests pass / 所有现有测试通过
  • I have added tests for new functionality / 我已为新功能添加测试
  • I have tested on the affected platform(s) / 我已在受影响的平台上测试
  • I have verified the changes work in the target browser(s) / 我已验证更改在目标浏览器中有效

Manual Testing Steps / 手动测试步骤

  1. Run pnpm build to generate the new directory structure
  2. Verify output directory structure shows dist/bundles/ instead of dist/src/
  3. Load the extension in Chrome via chrome://extensions (Developer mode → Load unpacked)
  4. Test basic extension functionality (content scripts, background worker, inject scripts)
  5. Verify all platform integrations still work correctly

Screenshots/Videos / 截图/视频

N/A - This is an internal directory structure refactoring with no visible UI changes.

Before:

dist/
├── src/
│   ├── background.js
│   ├── content.js
│   ├── inject.js
│   └── chunks/
└── assets/

After:

dist/
├── bundles/
│   ├── background.js
│   ├── content.js
│   ├── inject.js
│   └── chunks/
└── assets/

Reviewer Checklist / 审阅者清单

  • Code follows the project's style guidelines / 代码遵循项目的风格指南
  • Changes are well-documented / 更改有良好的文档说明
  • No breaking changes or clearly documented if present / 无破坏性更改,或已清楚记录
  • Security implications have been considered / 已考虑安全影响
  • Performance impact has been evaluated / 已评估性能影响
  • All discussions have been resolved / 所有讨论已解决

Additional Notes / 补充说明

This refactoring improves code clarity and follows naming conventions that better indicate the purpose of each directory:

  • bundles/ - Compiled, bundled JavaScript ready for browser execution
  • assets/ - Static assets (icons, manifest, etc.)

The change is non-breaking for end users as they only interact with the installed extension, not the build artifacts. However, any documentation or tooling that references the old dist/src/ path should be updated accordingly.

@timerring timerring self-assigned this Feb 7, 2026
@timerring timerring added the enhancement New feature or request label Feb 7, 2026
Copy link
Member Author

@timerring timerring left a comment

Choose a reason for hiding this comment

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

LGTM

@timerring timerring merged commit c2b13b2 into main Feb 7, 2026
@timerring timerring deleted the dev branch February 7, 2026 11:12
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.

[Bug]: Irregular build output structure

1 participant