-
-
Notifications
You must be signed in to change notification settings - Fork 432
TypeScript support: don't try to compile templates #1222
Conversation
Maybe add an extra check for the file extension and only disable for There is a usecase where you may want to compose the preload function: Also reusable preload functions: |
Thanks @thgh ! I've updated the regex to cover both the cases you mentioned. Take another look and let me know what you think
The code is typically in a |
I've been using this in my fork for the past few weeks and the only issue I ran into was if |
Another possibility might be https://github.com/Rich-Harris/tippex |
Cool. I'm happy to switch it out if you prefer. |
Well tippex seems to match the case we have here better because it also blanks out strings from its input, which strip-comments does not but which is needed to help avoid false positives. |
In the meantime, maybe we can only compile the module script block, until this is resolved? Like this: let matches;
if (/preload/.test(source) && (matches = source.match(/<script context="module">[^]*?<\/script>/))) {
try {
const { vars } = svelte.compile(matches[0], { generate: false });
return vars.some((variable: any) => variable.module && variable.export_name === 'preload');
} catch (err) {}
} The benefit would be, to use typescript in the other script block. |
I've gone ahead and switched this to use https://github.com/Rich-Harris/tippex |
The main thing I was keeping my eyes on with this PR is the fact that it uses a regex to extract the |
This was a good idea, but closing in favor of #1344, which is a better idea. |
Enables TypeScript support #760
TypeScript won't compile with Svelte compiler and first needs to be preprocessed. However, that happens after this check because
create_app
outputs JS which imports thesepreload
exports before we try to bundle the whole appThis also has to be much faster to build the mainfest!