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

Modernize deno template #9932

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from

Conversation

redabacha
Copy link
Contributor

@redabacha redabacha commented Sep 2, 2024

This modernizes the Deno template to use all the goodies of the releases over the past several years. It removes the need for a package.json file, any dependency on Node.js + npm and now uses Vite instead of the classic Remix compiler.

It also drops the need for the @remix-run/deno package, allowing it to be deprecated and removed in the future. I am not sure what the deprecation + removal process looks like for a remix package so I have opted to leave that out of this PR.

The new Deno template is currently setup to lint the app/ directory with eslint (which Deno can run) in order to align more closely with how the other templates are setup and provide better linting rules and flexibility which is needed for web development, e.g. eslint-plugin-react-hooks gives the rules-of-hooks lint rule that Deno does not have.

Furthermore, typechecking is now done with typescript's tsc for all files with app/. This allows again for more flexibility by being able to control the typescript version and configuration independent of Deno. In order to provide Deno API access within the app/ directory (without running into typescript errors), a task called typegen can be run to generate the Deno specific declarations.

Closes: denoland/deno#20790

  • Docs
  • Tests

Copy link

changeset-bot bot commented Sep 2, 2024

🦋 Changeset detected

Latest commit: c5bc59b

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

This PR includes changesets to release 16 packages
Name Type
create-remix Minor
@remix-run/node Minor
@remix-run/dev Minor
@remix-run/architect Minor
@remix-run/express Minor
@remix-run/react Minor
@remix-run/serve Minor
@remix-run/testing Minor
remix Minor
@remix-run/cloudflare Minor
@remix-run/cloudflare-pages Minor
@remix-run/cloudflare-workers Minor
@remix-run/css-bundle Minor
@remix-run/deno Minor
@remix-run/eslint-config Minor
@remix-run/server-runtime 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

@redabacha redabacha changed the base branch from main to dev September 2, 2024 09:23
});
await execa(
pkgManager,
["install", ...(pkgManager === "deno" ? ["--no-lock"] : [])],
Copy link
Contributor Author

@redabacha redabacha Sep 2, 2024

Choose a reason for hiding this comment

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

the reason --no-lock is passed here is that deno v1 uses a different lockfile format to v2. when running deno install in deno v1 with DENO_FUTURE=1 set, it installs and creates a lockfile with the format of v2 which will cause errors running other deno commands without also setting DENO_FUTURE=1 env var as well. and deno install must be ran with DENO_FUTURE=1 set as deno v1's deno install does something entirely different with no good alternative (deno cache doesn't install all deps).

there's three solutions to this i can think of:

  • wait for deno 2 to release and only support that, currently there are release candidates available
  • force DENO_FUTURE=1 to be used for the entire project (i.e. when running any deno related command and afaik there is no configuration option for this)
  • do what is currently done here and don't create a lockfile in this step, let the user do it in their own time (e.g. when a command is ran like deno task dev or adding a new dependency to the project - both will automatically create the lockfile)

@redabacha redabacha force-pushed the modernize-deno-template branch 3 times, most recently from 5222ff2 to 7d7761a Compare September 2, 2024 19:12
let port = await getPort();
let cwd = await createProject(await files({ port }), template);

// Install dependencies as late as possible so Node won't accidentally import them and cause access denied errors in Deno on Windows
Copy link
Contributor Author

@redabacha redabacha Sep 3, 2024

Choose a reason for hiding this comment

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

Comment on lines 28 to +33
export function installGlobals({
nativeFetch,
}: { nativeFetch?: boolean } = {}) {
if (process.versions.deno) {
return;
}
Copy link
Contributor Author

@redabacha redabacha Sep 5, 2024

Choose a reason for hiding this comment

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

making installGlobals a no-op in Deno allows the @remix-run/serve cli to work without issues

@redabacha redabacha marked this pull request as ready for review September 5, 2024 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants