-
Notifications
You must be signed in to change notification settings - Fork 41
build: bundling configs for .node + proper import of setapp package #217
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
base: master
Are you sure you want to change the base?
Changes from all commits
eaf00bf
4858c06
0e7260d
cf405f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,10 @@ export default { | |
| loader: "ts-loader", | ||
| }, | ||
| }, | ||
| { | ||
| test: /\.node$/, | ||
| loader: "node-loader", | ||
| }, | ||
| ], | ||
| }, | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,14 @@ import logger from "../utils/logger"; | |||||||||||||||||||||||||||||||||
| import { setupIPCForwardingToWebApp } from "./actions/setupIPCForwarding"; | ||||||||||||||||||||||||||||||||||
| import { saveCookies } from "./actions/cookiesHelpers"; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if (process.env.IS_SETAPP_BUILD === "true") { | ||||||||||||||||||||||||||||||||||
| log.log("[SETAPP] build identified") | ||||||||||||||||||||||||||||||||||
| const setappFramework = require("@setapp/framework-wrapper"); | ||||||||||||||||||||||||||||||||||
| setappFramework.SetappManager.shared.reportUsageEvent(setappFramework.SETAPP_USAGE_EVENT.USER_INTERACTION); | ||||||||||||||||||||||||||||||||||
| log.log("[SETAPP] integration complete") | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+33
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Add error handling for optional dependency. The dynamic Apply this diff to add proper error handling: if (process.env.IS_SETAPP_BUILD === "true") {
log.log("[SETAPP] build identified")
- const setappFramework = require("@setapp/framework-wrapper");
- setappFramework.SetappManager.shared.reportUsageEvent(setappFramework.SETAPP_USAGE_EVENT.USER_INTERACTION);
- log.log("[SETAPP] integration complete")
+ try {
+ const setappFramework = require("@setapp/framework-wrapper");
+ setappFramework.SetappManager.shared.reportUsageEvent(setappFramework.SETAPP_USAGE_EVENT.USER_INTERACTION);
+ log.log("[SETAPP] integration complete")
+ } catch (error) {
+ log.error("[SETAPP] Failed to initialize Setapp framework:", error);
+ }
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents🧩 Analysis chainVerify webpack bundling of optional dependency. The dynamic Run the following script to check if the Setapp framework is properly bundled in production builds: 🏁 Script executed: #!/bin/bash
# Description: Verify that @setapp/framework-wrapper is available in production builds
# Check if the package is present in release/app/node_modules
if [ -d "release/app/node_modules/@setapp/framework-wrapper" ]; then
echo "✓ @setapp/framework-wrapper found in release/app/node_modules"
ls -la release/app/node_modules/@setapp/framework-wrapper/
else
echo "✗ @setapp/framework-wrapper NOT found in release/app/node_modules"
fi
# Check webpack externals configuration
echo "Checking webpack externals configuration..."
rg -n "externals" .erb/configs/webpack.config.base.ts -A 5
# Check if @setapp/framework-wrapper is in the externals list
echo "Verifying if @setapp/framework-wrapper is externalized..."
rg -n "@setapp/framework-wrapper" release/app/package.jsonLength of output: 429 🏁 Script executed: #!/bin/bash
# Check if @setapp/framework-wrapper is in root node_modules
echo "=== Checking root node_modules ==="
if [ -d "node_modules/@setapp/framework-wrapper" ]; then
echo "✓ @setapp/framework-wrapper found in root node_modules"
else
echo "✗ @setapp/framework-wrapper NOT found in root node_modules"
fi
# Check main package.json
echo ""
echo "=== Checking root package.json for @setapp/framework-wrapper ==="
rg -n "@setapp/framework-wrapper" package.json
# Check release/app package.json structure
echo ""
echo "=== Checking release/app/package.json dependencies section ==="
rg -n "dependencies" release/app/package.json -A 20 | head -30
# Check webpack config for how externals are handled in the actual build
echo ""
echo "=== Checking if there are webpack plugins or special handling for externals ==="
rg -n "externals|optional|@setapp" .erb/configs/ -B 2 -A 2Length of output: 1673 🏁 Script executed: #!/bin/bash
# Check the actual code context around the require statement
echo "=== Checking code context for error handling ==="
rg -n "require.*@setapp" src/main/main.ts -B 10 -A 5
# Check if there's a try-catch or conditional check
echo ""
echo "=== Checking for error handling patterns ==="
rg -n "try|catch|optional|IS_SETAPP_BUILD" src/main/main.ts -B 2 -A 2
# Check webpack config to see if optionalDependencies should be included
echo ""
echo "=== Full webpack externals configuration ==="
rg -n "externals" .erb/configs/webpack.config.base.ts -B 5 -A 10Length of output: 2721 🏁 Script executed: #!/bin/bash
# Check the actual code context around the require statement
echo "=== Checking code context for error handling ==="
rg -n "require.*@setapp" src/main/main.ts -B 10 -A 5
# Check if there's a try-catch or conditional check
echo ""
echo "=== Checking for error handling patterns ==="
rg -n "try|catch|optional|IS_SETAPP_BUILD" src/main/main.ts -B 2 -A 2
# Check webpack config to see if optionalDependencies should be included
echo ""
echo "=== Full webpack externals configuration ==="
rg -n "externals" .erb/configs/webpack.config.base.ts -B 5 -A 10Length of output: 2721 Wrap require() in try-catch or update webpack config to handle optional dependencies. The code lacks error handling for a dynamic require of an optional dependency. The package Fix one of:
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Init remote so that it could be consumed in renderer | ||||||||||||||||||||||||||||||||||
| const remote = require("@electron/remote/main"); | ||||||||||||||||||||||||||||||||||
| remote.initialize(); | ||||||||||||||||||||||||||||||||||
|
|
@@ -427,15 +435,7 @@ app.on("window-all-closed", () => { | |||||||||||||||||||||||||||||||||
| app | ||||||||||||||||||||||||||||||||||
| .whenReady() | ||||||||||||||||||||||||||||||||||
| .then(() => { | ||||||||||||||||||||||||||||||||||
| if (process.env.IS_SETAPP_BUILD === "true") { | ||||||||||||||||||||||||||||||||||
| log.log("[SETAPP] build identified") | ||||||||||||||||||||||||||||||||||
| const setappFramework = require("@setapp/framework-wrapper"); | ||||||||||||||||||||||||||||||||||
| setappFramework.SetappManager.shared.reportUsageEvent(setappFramework.SETAPP_USAGE_EVENT.USER_INTERACTION); | ||||||||||||||||||||||||||||||||||
| log.log("[SETAPP] integration complete") | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| app.on("activate", () => { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // On macOS it's common to re-create a window in the app when the | ||||||||||||||||||||||||||||||||||
| // dock icon is clicked and there are no other windows open. | ||||||||||||||||||||||||||||||||||
| if (BrowserWindow.getAllWindows().length === 0) { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major: Reconsider USER_INTERACTION event timing.
Reporting a
USER_INTERACTIONusage event immediately on app startup (before any actual user interaction) seems semantically incorrect. This event type typically signifies actual user engagement with the application. Consider either:APP_LAUNCHor similar)🤖 Prompt for AI Agents