Comments (4)
I also noted that the compilation
seem go fine, but the final output does not work :
(base) raphy@pc:~/ViteElectronReactBuilder$ yarn compile
yarn run v1.22.18
$ cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.js --dir --config.asar=false
> build
> npm run build:main && npm run build:preload && npm run build:renderer
> build:main
> cd ./packages/main && vite build
vite v3.0.0-alpha.11 building SSR bundle for production...
✓ 3 modules transformed.
dist/index.cjs 1.92 KiB
dist/index.cjs.map 9.82 KiB
> build:preload
> cd ./packages/preload && vite build
vite v3.0.0-alpha.11 building SSR bundle for production...
✓ 3 modules transformed.
rendering chunks (1)...Sourcemap is likely to be incorrect: a plugin (unplugin-auto-expose-preload) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
dist/index.cjs 0.44 KiB
dist/index.cjs.map 0.09 KiB
> build:renderer
> cd ./packages/renderer && vite build
vite v3.0.0-alpha.11 building for production...
transforming (7) ../../node_modules/.vite/deps_build/react.js'jsx' is not exported by '../../node_modules/react/jsx-runtime.js'
'jsxs' is not exported by '../../node_modules/react/jsx-runtime.js'
'Fragment' is not exported by '../../node_modules/react/jsx-runtime.js'
✓ 10 modules transformed.
dist/index.html 0.36 KiB
dist/index.46c79699.js 139.70 KiB / gzip: 45.14 KiB
dist/index.46c79699.js.map 419.83 KiB
• electron-builder version=23.0.3 os=5.13.0-51-generic
• loaded configuration file=/home/raphy/ViteElectronReactBuilder/.electron-builder.config.js
• writing effective config file=dist/builder-effective-config.yaml
• packaging platform=linux arch=x64 electron=19.0.4 appOutDir=dist/linux-unpacked
• asar usage is disabled — this is strongly not recommended solution=enable asar and use asarUnpack to unpack files that must be externally available
• asar usage is disabled — this is strongly not recommended solution=enable asar and use asarUnpack to unpack files that must be externally available
Done in 4.80s.
(base) raphy@pc:~/ViteElectronReactBuilder/dist/linux-unpacked$ ls -lah
total 186M
drwxrwxr-x 4 raphy raphy 4.0K Jun 17 12:06 .
drwxrwxr-x 3 raphy raphy 4.0K Jun 17 12:06 ..
-rw-r--r-- 1 raphy raphy 126K Jun 17 12:06 chrome_100_percent.pak
-rw-r--r-- 1 raphy raphy 177K Jun 17 12:06 chrome_200_percent.pak
-rwxr-xr-x 1 raphy raphy 1.1M Jun 17 12:06 chrome_crashpad_handler
-rwxr-xr-x 1 raphy raphy 50K Jun 17 12:06 chrome-sandbox
-rw-r--r-- 1 raphy raphy 10M Jun 17 12:06 icudtl.dat
-rwxr-xr-x 1 raphy raphy 238K Jun 17 12:06 libEGL.so
-rwxr-xr-x 1 raphy raphy 2.9M Jun 17 12:06 libffmpeg.so
-rwxr-xr-x 1 raphy raphy 6.0M Jun 17 12:06 libGLESv2.so
-rwxr-xr-x 1 raphy raphy 4.1M Jun 17 12:06 libvk_swiftshader.so
-rwxr-xr-x 1 raphy raphy 5.6M Jun 17 12:06 libvulkan.so.1
-rw-r--r-- 1 raphy raphy 1.1K Jun 17 12:06 LICENSE.electron.txt
-rw-r--r-- 1 raphy raphy 5.1M Jun 17 12:06 LICENSES.chromium.html
drwxrwxr-x 2 raphy raphy 4.0K Jun 17 12:06 locales
drwxrwxr-x 3 raphy raphy 4.0K Jun 17 12:06 resources
-rw-r--r-- 1 raphy raphy 4.9M Jun 17 12:06 resources.pak
-rw-r--r-- 1 raphy raphy 398K Jun 17 12:06 snapshot_blob.bin
-rw-r--r-- 1 raphy raphy 714K Jun 17 12:06 v8_context_snapshot.bin
-rwxr-xr-x 1 raphy raphy 145M Jun 17 12:06 vite-electron-builder
-rw-r--r-- 1 raphy raphy 107 Jun 17 12:06 vk_swiftshader_icd.json
May be it's related to the Sourcemap
issue, or, may be not
from unplugin-auto-expose.
Ran into the same problem, the sourcemap seemed incorrect.
from unplugin-auto-expose.
After hours of digging out how sourcemap works, here's what I found:
The Plugin
This repository is a bundle of two Rollup plugins: preload (unplugin-auto-expose-preload
) and renderer (unplugin-auto-expose-renderer
).
The preload plugin calls electron's contextBridge.exposeInMainWorld
API to expose exports in preload as __electron_preload__${exp}
where exp
is the exported name by appending to the end of code.
The renderer plugin scans the preload exports by mlly
, and then resolves any import { exp } from '#preload'
(that's not configurable currently) by appending export const exp = globalThis.__electron_preload_exp
to the end of code.
The Sourcemap
The sourcemap uses Base64 VLQ coding to describe the mappings of source code and the transformed. More info can be found at here and there.
The Problem
According to rollup's API (You can find one with detailed return types here), the return types of load
hook (actually transform
hook is recommanded to use here btw) used in these plugins are string | null | {code: string, map?: string | SourceMap, ast? : ESTree.Program, moduleSideEffects?: boolean | "no-treeshake" | null, syntheticNamedExports?: boolean | string | null, meta?: {[plugin: string]: any} | null}
. Unfortunately these plugins returns string
instead of { code: string, map?:string }
so the sourcemap WILL be lost here. That's the root of this issue.
The Solution
Other plugins like rollup-plugin-insert
uses magic-string
for sourcemap manipulating such as appending to the source code, so you needn't calculate the mappings in the complex Base64 VLQ encoding by yourself. So use magic-string
to loads the original code, append the exports, generate sourcemap and return it should solve this problem.
from unplugin-auto-expose.
I am currently very busy volunteering in Ukraine. Not sure when I'll have time to fix it. But pr are welcome
from unplugin-auto-expose.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unplugin-auto-expose.