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

Path with Closing Parenthesis Breaks Resource Loading in Parcel + Electron Bundle #10096

Open
XRealSys opened this issue Feb 26, 2025 · 0 comments

Comments

@XRealSys
Copy link

XRealSys commented Feb 26, 2025

Description:
When packaging an Electron application using Parcel, if the application's installation path contains a closing parenthesis ), resources fail to load properly. This occurs because the generated runtime.js incorrectly truncates the base URL at the closing parenthesis when using string splitting in the getBundleURL function.

Steps to Reproduce:

Create an Electron app with Parcel bundling

Package the application using parcel build

Place the built application in a path containing closing parenthesis (e.g., C:/test/test ) folder/dist/)

Launch the packaged application

Observe failed resource loading in DevTools console

Expected Result:
Application should load resources normally regardless of special characters in the path.

Actual Result:
Resources fail to load with network errors. The generated base URL in runtime.js becomes truncated:

// Current broken output:
const baseUrl = "file:///C:/test/test " // Truncated at closing parenthesis

// Expected behavior:
const baseUrl = "file:///C:/test/test ) folder/dist/" // Full path with escaped characters

Root Cause Analysis:
The issue originates from how index.runtime.[public-id].js calculates the base URL:

t.getBundleURL = function (e) {
    var r = n[e];
    return r || (r = function () {
        try {
            throw Error();
        } catch (r) {
            var e = ("" + r.stack).match(/(https?|file|ftp|(chrome|moz|safari-web)-extension):\/\/[^)\n]+/g);
            if (e) return o(e[2]);
        }
        return "/";
    }(), n[e] = r), r;
};

The current implementation uses simple string splitting that doesn't account for special characters like closing parentheses, causing incorrect path resolution.

Environment:

OS: Windows 10/11 (path-related issue)

Parcel version: 2.13.3

Possible Solutions:

While I'm aware the v2 branch has adopted a revised implementation, I'm uncertain whether path-related issues (like parenthesis truncation) could still manifest.

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

No branches or pull requests

1 participant