arc-electron
repository is a shell application that bundles the components and provides platform (Electron) specific bindings like persistence layer, file system access, update service, and more. You can learn more about the the architecture for salable application in this Medium article.application/javascript
content type. Electron doesn't add mime types for files in the application sources. Because of that, modules cannot run natively in an Electron application. Moreover, to import another module in a module it must use relative or absolute paths (staring with .
or /
). The industry standard, however, is to point to an NPM module without resolving paths. This results with a different approach in ARC: to use the protocol handlers. The application internally registers a custom scheme (web-module:
) for loading files. When the file is being loaded the handler resolves the path to the module (in order: ./src/
, ./web_modules/
, and node_modules
) and returns the file content with a proper mime type. See src/io/EsmProtocol.js
for detailed implementation.src/io/WindowsManager.js
which takes care of the proper scheme when loading files.preload
script, which is executed before the window is loaded. This script has full node and file system access. Inside this script we create interfaces and proxies the application uses to run node modules or to communicate with the main (IO) process. All preload
proxies and interfaces are located in the src/preload
folder. GoogleDriveProxy
class allows to perform few operations like listing application folder, getting a file, or storing a file on Google Drive. This proxy just passes data to the main process which performs the authentication and the actual operation. This creates a security layer so external script loaded in the renderer process don't have access to all APIs.@pika/web
project (now it's snowflake) to resolve and cache modules in a very accessible way. This requires additional step of configuring the package.json
file and the @pika/web.webDependencies
entry adding each script to the build process. When the npm i
script runs it also run the prepare
script that eventually runs pika-web
CLI tool. In the renderer process we don't point to node_modules
but directly to the files in the web_modules
directory. In fact most UI dependencies are installed in the dev dependencies which means they are not included in the final build of the application.