Skip to content

Comments

Refactor build#2123

Merged
marcelklehr merged 3 commits intodevelopfrom
refactor/fail-build-if-native-uses-browser-api
Dec 14, 2025
Merged

Refactor build#2123
marcelklehr merged 3 commits intodevelopfrom
refactor/fail-build-if-native-uses-browser-api

Conversation

@marcelklehr
Copy link
Member

No description provided.

…browser-api

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the webpack build configuration to split browser and native builds into separate configurations, introducing a compile-time IS_BROWSER constant to replace runtime Capacitor.getPlatform() checks. It also adds a build guard to ensure the native build doesn't accidentally include references to browser-specific APIs.

Key changes:

  • Split webpack configuration into two separate configs (browser and native) with separate IS_BROWSER flags
  • Replace runtime Capacitor.getPlatform() checks with compile-time IS_BROWSER constant across adapters and core files
  • Add build validation in gulpfile.js to detect browser-api references in native chunks

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
webpack.common.js Restructured to export an array of two configurations (browser and native), each with their own IS_BROWSER definition via DefinePlugin
webpack.prod.js Updated to handle array of configurations using .map()
webpack.dev.js Updated to handle array of configurations using .map()
src/ui/plugins/capacitor.js Replaced Capacitor.getPlatform() check with IS_BROWSER global
src/lib/adapters/WebDav.ts Replaced multiple Capacitor.getPlatform() checks with IS_BROWSER
src/lib/adapters/NextcloudBookmarks.ts Replaced Capacitor.getPlatform() checks with IS_BROWSER
src/lib/adapters/Linkwarden.ts Replaced Capacitor.getPlatform() checks with IS_BROWSER
src/lib/adapters/Karakeep.ts Replaced Capacitor.getPlatform() checks with IS_BROWSER
src/lib/adapters/GoogleDrive.ts Refactored authorization flow and replaced most Capacitor.getPlatform() checks with IS_BROWSER
src/lib/adapters/Git.ts Replaced Capacitor.getPlatform() check with IS_BROWSER
src/lib/Logger.js Replaced Capacitor.getPlatform() checks with IS_BROWSER
src/lib/Controller.ts Replaced Capacitor.getPlatform() checks with IS_BROWSER
src/lib/Account.ts Replaced Capacitor.getPlatform() checks with IS_BROWSER, added conditional imports for offscreen module
gulpfile.js Added webpackCheck() function to validate native build doesn't contain browser-api references, updated HTML generation to handle multiple webpack configs
tsconfig.json Changed TypeScript target from es5 to es6
package.json Updated babel-loader version constraint and modified browserslist with more specific ES6 support requirements
package-lock.json Dependency version updates reflecting package.json changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…r doesn't match

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr marcelklehr changed the title chore(build): Add guard against native build containing reference browser-api Refactor build Dec 14, 2025
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr marcelklehr merged commit 3fcfcfd into develop Dec 14, 2025
29 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant