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

Implement node wrapper #298

Merged
merged 2 commits into from
Dec 14, 2020
Merged

Implement node wrapper #298

merged 2 commits into from
Dec 14, 2020

Conversation

72636c
Copy link
Member

@72636c 72636c commented Dec 14, 2020

See changesets and README for full details. Closes #84.


skuba node runs a TypeScript file; it's like a one-off skuba start. Unlike start, it gives you a REPL when you omit the command line entry point rather than falling back to the entry point in package.json.

This PR also adds some secret sauce to automatically register the src module alias when you're running under skuba node or skuba start. This means that you only need a runtime module alias resolver like import skuba-dive/register at the top of production entry points; local scripts can be run with little fanfare using the skuba commands.


Notes:

  • I considered calling the command skuba exec, but that sounds a bit awkward when it supports opening a REPL.

  • You may be wondering why don't we just use tsconfig-paths.

    This is tempting but I'm not convinced that we should depend on reading configuration out of tsconfig.json at runtime. This can be confusing given TypeScript is generally considered a compile-time concern, and our own templates only keep lib and node_modules in the runtime Docker image.

  • Diving into this has uncovered that the @babel/node REPL is pretty unusable with modern JavaScript/TypeScript. See the README for more.

See changesets and README for full details.

---

`skuba node` runs a TypeScript file; it's like a one-off `skuba start`.
Unlike start, it gives you a REPL when you omit the command line entry
point rather than falling back to the entry point in `package.json`.

This PR also adds some secret sauce to automatically register the `src`
module alias when you're running under `skuba node` or `skuba start`.
This means that you only need a runtime module alias resolver like
`import skuba-dive/register` at the top of production entry points;
local scripts can be run with little fanfare using the skuba commands.

---

Notes:

- I considered calling the command `skuba exec`, but that sounds a bit
  awkward when it supports opening a REPL.

- You may be wondering why don't we just use `tsconfig-paths`.

  This is tempting but I'm not convinced that we should depend on
  reading configuration out of `tsconfig.json` at runtime. This can be
  confusing given TypeScript is generally considered a compile-time
  concern, and our own templates only keep `lib` and `node_modules` in
  the runtime Docker image.

- Diving into this has uncovered that the `@babel/node` REPL is pretty
  unusable with modern JavaScript/TypeScript. See the README for more.
@72636c 72636c requested a review from a team as a code owner December 14, 2020 02:09
@changeset-bot
Copy link

changeset-bot bot commented Dec 14, 2020

🦋 Changeset detected

Latest commit: 17e3574

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

This PR includes changesets to release 1 package
Name Type
skuba 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

Copy link

@tobyhei tobyhei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

Copy link
Contributor

@etaoins etaoins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@72636c 72636c merged commit 641accc into master Dec 14, 2020
@72636c 72636c deleted the node-command branch December 14, 2020 02:38
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.

skuba exec
3 participants