Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from cawa-93/esm
Browse files Browse the repository at this point in the history
Added PoC of esm support
  • Loading branch information
cawa-93 authored Jan 11, 2024
2 parents ed8af76 + 9f1221c commit ed21335
Show file tree
Hide file tree
Showing 19 changed files with 978 additions and 154 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
working-directory: playground

- run: npm run build:main
working-directory: playground
- run: npm run build:preload
working-directory: playground
- run: npm run build:renderer
working-directory: playground

- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm test
working-directory: playground
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/git_toolbox_prj.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/jsLibraryMappings.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,32 @@ Plugins for automatic `exposeInMainWorld`. Easily export your exposed api from `
// preload.ts
export const foo = 'foo string'
// Equivalent
electron.contextBridge.exposeInMainWorld('__electron_preload_foo__', 'foo string')
electron.contextBridge.exposeInMainWorld('__electron_preload_foo', 'foo string')
```
```ts
// renderer.ts
import {foo} from '#preload'
// Equivalent
const foo = window.__electron_preload_foo__
const foo = window.__electron_preload_foo
```

## Limitation
Only _named exports_ are supported.
## Supports all export declaration

```ts
export * from 'file' // ❌ Will not work
export {prop} from 'file' //
// Export named declaration
export const prop = 1
export function method() {}

// Named Re-export
export {prop} from 'file'
export {prop as propAlias} from 'file'

export * as props from 'file' // ❌ Will not work
import * as file from 'file'
export const props = file // ⚠ Will work but not recommended for security reasons
// Export all declaration
export * from 'file'
export * as props from 'file'

// Default exports
export default 'foo'
```

## Configuration
Expand Down Expand Up @@ -65,7 +73,7 @@ export default defineConfig({
## TypeScript
To configure the TypeScript, add a path to your renderer.

```ts
```json5
// tsconfig.json`:
{
"compilerOptions": {
Expand Down
Loading

0 comments on commit ed21335

Please sign in to comment.