vite-electron-builder icon indicating copy to clipboard operation
vite-electron-builder copied to clipboard

build: use vite to bundle deps at main/preload package under ssr mode.

Open Tanimodori opened this issue 2 years ago • 6 comments

See previous try #903 for more details.

Tanimodori avatar Feb 13 '23 08:02 Tanimodori

The dev/prod build was successful on my Windows 10 env. The tests failed because of https://github.com/vitest-dev/vitest/issues/2806 .

Tanimodori avatar Feb 13 '23 08:02 Tanimodori

electron-builtins no more needed?

cawa-93 avatar Feb 13 '23 13:02 cawa-93

No. electron-builtins just wraps electron sub-modules. This package is essentially:

module.exports = [
	// API root
	'electron',

	// common modules
	'clipboard',
	'crash-reporter',
	'deprecations',
	'nativeImage',
	'shell',

        // ...
];

All modules besides electron are sub-modules of electron, which are usually wrote as:

import { clipboard } from 'electron'

But never

import * as clipboard from 'clipboard'

So we just need to externalize electron.

Tanimodori avatar Feb 13 '23 13:02 Tanimodori

Note: If you turned off nodeIntergration for preload package (for example you need to sandbox your preload), you need to disable preserveModules as the require here in preload is polyfilled by electron which cannot resolve multiple files as stated in https://github.com/electron/electron/issues/35587#issuecomment-1238940105

Tanimodori avatar Feb 14 '23 08:02 Tanimodori

Hello. I apologize for the delay. Due to... known reasons... I have very little free time. I plan to merge this. But I'd like to wait until the https://github.com/vitest-dev/vitest/issues/2806 issue is resolved so as not to confuse users. Also, I feel that there needs to be some kind of additional documentation in the readme to explain how dependencies work and how they are bundled and delivered to the end user.

cawa-93 avatar Mar 03 '23 21:03 cawa-93

https://github.com/rollup/rollup/issues/4905 is fixed.

Tanimodori avatar Mar 20 '23 07:03 Tanimodori

Hello. Thank you again for the fantastic job you did. I still think this is a good idea and will definitely keep an eye on it.

Unfortunately, due to the war in my country, I have less and less energy to maintain this project. Recently, major changes have taken place and I have moved this template entirely to the ESM.

In this regard, I consider the implementation in this PR to be outdated and conflicted. I will close it now and try to return to it at some point.

cawa-93 avatar May 23 '24 09:05 cawa-93