Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skywalker13/import-asar-bug
https://github.com/skywalker13/import-asar-bug
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/skywalker13/import-asar-bug
- Owner: Skywalker13
- Created: 2022-07-11T13:43:21.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-07-11T13:58:58.000Z (over 2 years ago)
- Last Synced: 2024-11-14T12:55:06.543Z (2 months ago)
- Language: JavaScript
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# import-asar-bug
The `import()` function which can be used to load es6 module into commonjs module is broken when an app is package as app.asar. It doesn't work even if it's deployed into the `app.asar.unpacked` directory. It works only when asar is disabled.
```
npm i
```## Working
```
node_modules/.bin/electron .
``````
npm run good
dist/mac-arm64/import-asar-bug.app/Contents/MacOS/import-asar-bug
```## Broken
When electron is used with app.asar, it's broken
```
npm run bad
dist/mac-arm64/import-asar-bug.app/Contents/MacOS/import-asar-bug
(node:31052) UnhandledPromiseRejectionWarning: Error: ENOTDIR: not a directory, stat '/Users/epsitec/devel/import-asar-bug/dist/mac-arm64/import-asar-bug.app/Contents/Resources/app.asar/lib/my-commonjs/node_modules/my-module'
at statSync (node:fs:1538:3)
at tryStatSync (node:internal/modules/esm/resolve:184:13)
at packageResolve (node:internal/modules/esm/resolve:899:18)
at moduleResolve (node:internal/modules/esm/resolve:978:18)
at defaultResolve (node:internal/modules/esm/resolve:1080:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ESMLoader.import (node:internal/modules/esm/loader:332:22)
at importModuleDynamically (node:internal/modules/cjs/loader:1049:29)
at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)```