Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[labs/testing] Add option for worker modules and TypeScript support for SSR worker #4730

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kyubisation
Copy link
Contributor

@kyubisation kyubisation commented Aug 13, 2024

Closes #3557

This PR adds an option to the litSsrPlugin to support TypeScript files. This uses @swc/wasm for the transpilation. The official Node.js TypeScript integration uses a variant of this without decorator support: https://github.com/nodejs/amaro
Additionally, an option is added to allow defining worker modules, which are sequentially imported at the start of the SSR worker. This allows registering Node.js hooks (https://nodejs.org/api/module.html#customization-hooks) or general setup.

/**
 * These modules will be imported from each newly created worker.
 * (A worker is created for each call to render a template via SSR).
 * This allows registering hooks for Node.js or general setup.
 */
workerModules?: string[];
/**
 * Whether to transpile TypeScript files.
 */
typeScript?: boolean | { tsconfig?: string };

Copy link

changeset-bot bot commented Aug 13, 2024

🦋 Changeset detected

Latest commit: 1961b2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lit-labs/testing Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kyubisation
Copy link
Contributor Author

kyubisation commented Aug 13, 2024

I'm not quite confident with the naming of initScript and open to suggestions for changes.
Settled on workerModules.

@augustjk augustjk self-requested a review August 19, 2024 19:14
@kyubisation kyubisation changed the title [labs/testing] Add option for init script for ssr worker to allow registering Node.js hooks [labs/testing] Add option for worker modules for SSR worker and TypeScript hook implementation Sep 17, 2024
@kyubisation
Copy link
Contributor Author

@augustjk I updated the PR as discussed during the community call. Can I ask you for a review?
If you would like to discuss it via call, I am reachable via Discord during CEST (currently UTC+2) time zone business hours (or later).

@bennypowers
Copy link
Collaborator

this would be very helpful with the eleventy plugin - we could avoid tsc in eleventy.before and save a lot of time restarting the dev server after one-line changes

@kyubisation kyubisation changed the title [labs/testing] Add option for worker modules for SSR worker and TypeScript hook implementation [labs/testing] Add option for worker modules and TypeScript support for SSR worker Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[labs/testing] Make WTR plugin work with on-the-fly ts compilation
2 participants