-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the problem
svelte-package currently works as follows 1) Empty dist/ 2) generate Svelte types 3) Emit ts-types. Step 2) and 3) take LOOONG. So if a site-1 depends on package-1, While step 2 and 3 are happening Vite HMR in site-1 sees that there are no files and crashes unrecoverably.
Describe the proposed solution
Change the algorithm to the following:
- Empty
./svelte-kit/__package__: - generate Svelte & TS types into
./.svelte-kitfolder - Copy output from into
./svelte-kit/__package__todist/
https://github.com/sveltejs/kit/blob/master/packages/package/src/index.js#L31
- rimraf(output);
- mkdirp(output);
+ rimraf(temp);
+ mkdirp(temp);
const files = scan(input, extensions);
if (options.types) {
- await emit_dts(input, output, options.cwd, alias, files);
+ await emit_dts(input, temp, options.cwd, alias, files);
}
for (const file of files) {
- await process_file(input, output, file, options.config.preprocess, alias, analyse_code);
+ await process_file(input, temp, file, options.config.preprocess, alias, analyse_code);
}
+ rimraf(output);
+ mkdirp(output);
+ copy(temp, output);It takes slightly longer because of the copying but it doesn't break apps that are depending dist/.
Alternatives considered
The more nuclear option is to avoid svelte-package altogether and generate types using svelte2tsx using a build script. In a monorepo setup you can get away with not pre-processing etc. and do it in the consuming application.
Importance
would make my life easier
Additional Information
No response