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

feat: create official Netlify Remix template #83

Merged
merged 43 commits into from
Feb 24, 2023

Conversation

nickytonline
Copy link
Contributor

@nickytonline nickytonline commented Feb 10, 2023

Description

Updates the template. The updated template uses remix.init to offer installing Remix for Netlify Functions or for Netlify Edge Functions. The Netlify Functions template existed already within Remix, but when I was working on remix-run/remix#3104, we turned it into one template, extending the template via remix.init to choose between Netlify Functions and Netlify Edge Functions.

Ignore the deploy preview loading with a page not found. The template has changed and a deploy preview does not make sense at the moment. We'll need to rethink how we deploy the different templates as a deploy preview.

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

  1. Ensure the Netlify CLI is installed and up to date.

  2. Check out this branch, e.g. via the GitHub CLI, gh co 83

  3. There are four test scenarios:

    • Create a Remix app using TypeScript for Netlify Functions
    • Create a Remix app using JavaScript for Netlify Functions
    • Create a Remix app using TypeScript for Netlify Edge Functions
    • Create a Remix app using JavaScript for Netlify Edge Functions
  4. For each scenario, it always starts by running the following from the root folder in a shell.

npx create-remix --template ./
  1. The CLI will prompt for a location for the project.
❯ npx create-remix --template ./
? Where would you like to create your app? (./my-remix-app)

Ensure that the location is outside of the Netlify Remix template folder, e.g. ../my-remix-app

  1. The Remix CLI will prompt you to choose TypeScript or JavaScript. Choose accordingly for the given test scenarios mentioned above.
? TypeScript or JavaScript? (Use arrow keys)
❯ TypeScript 
  JavaScript
  1. The Remix CLI will prompt you to install packages, press the ENTER to accept the default answer of Yes
? Do you want me to run `npm install`? (Y/n)

The npm packages will install.

  1. Some files will be manipulated if JavaScript is selected. The Remix CLI will output something similar to this.
⠹ Creating your app…⠋ Migrating template to JavaScript…Processing 3 files... 
Spawning 3 workers...
Sending 1 files to free worker...
Sending 1 files to free worker...
Sending 1 files to free worker...
⠴ Migrating template to JavaScript… SKIP /Users/nicktaylor/dev/remix-tests/edgy-ts/globals.d.ts
⠦ Migrating template to JavaScript… OKK /Users/nicktaylor/dev/remix-tests/edgy-ts/remix.init/root.tsx
 OKK /Users/nicktaylor/dev/remix-tests/edgy-ts/remix.init/entry.server.tsx
All done. 
Results: 
0 errors
0 unmodified
1 skipped
2 ok
Time elapsed: 0.428seconds
  1. The Remix CLI extended with our questions will prompt to create the app with Netlify Functions or Netlify Edge Functions.
💿 Running remix.init script
? Run your Remix site with: (Use arrow keys)
❯ Netlify Functions - Choose this for stable support for production sites 
  Netlify Edge Functions (beta) - Try this for improved performance on non-critical sites

Choose accordingly for the given test scenarios mentioned above.

  1. Change to the directory of the project you just created, e.g. ../my-remix-app
  2. Note that the newly created project should not contain a .github folder
  3. The README.md for the project should be for the given deployment target. If you created a new Remix app using the Netlify Functions template, it should have this README. Otherwise, it should be this README.
  4. The netlify.toml for the project should be for the given deployment target. If you created a new Remix app using the Netlify Functions template, it should have this netlify.toml. Otherwise, it should be this netlify.toml.
  5. Run npm install
  6. Run ntl build --offline
  7. Run ntl serve
  8. Navigate to https://localhost:8888 and the page loads.

image

Testing a deployment

If you want to test a deploy of your new Remix app created by the Remix template:

  1. Ensure you're logged in to Netlify via the CLI
ntl login
  1. Create a new site:
ntl init
  1. Deploy the site:
ntl deploy --build 

or for production

ntl deploy --build --prod

For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we
    can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style
    guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

A hamster cleaning their face

@nickytonline nickytonline self-assigned this Feb 10, 2023
@netlify
Copy link

netlify bot commented Feb 10, 2023

Deploy Preview for remix-edge-on ready!

Name Link
🔨 Latest commit be32ac6
🔍 Latest deploy log https://app.netlify.com/sites/remix-edge-on/deploys/63f910678bbe4600087ab1f8
😎 Deploy Preview https://deploy-preview-83--remix-edge-on.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions bot added the type: chore work needed to keep the product and development running smoothly label Feb 10, 2023
@nickytonline nickytonline changed the title chore: updated eslint configuration for template chore: update template Feb 10, 2023
@nickytonline nickytonline requested a review from a team February 10, 2023 03:43
@nickytonline nickytonline force-pushed the nickytonline/update-template branch 2 times, most recently from bdd6833 to ba24c63 Compare February 22, 2023 21:18
["server.js"],
["remix.config.js"],
["entry.server.tsx", "app/entry.server.tsx"],
["vscode.json", ".vscode/settings.json"],
];

const filesToCopy = [["README.md"], ["netlify.toml"]];
const filesToCopy = [["README.md"], ["netlify-toml", "netlify.toml"]];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remix.init was ignoring *.toml files, so I renamed the template files.

@nickytonline
Copy link
Contributor Author

I fixed the issues with the JS template generation @sarahetter @taty2010. There is one issue currently for the generation of the edge template for a JavaScript project. When the Remix CLI converts files to JS, it translates the ESM import isbot from "isbot" to this require, const isbot = require("isbot").default, when it should be const isbot = require("isbot"). I'm going to fix it for our template, and raise an issue in the Remix repository. I haven't looked at the code, but it looks like it thinks import something from "something" means default import automatically, e.g. const something = require("something").default.

@@ -47,6 +47,25 @@ Open up [http://localhost:3000](http://localhost:3000), and you should be ready

Note: When running the Netlify CLI, file changes will rebuild assets, but you will not see the changes to the page you are on unless you do a browser refresh of the page. Due to how the Netlify CLI builds the Remix App Server, it does not support hot module reloading.

### Excluding routes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a new section I added @stephmarie17. Could the wording be improved?

Copy link
Contributor

Choose a reason for hiding this comment

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

Left a suggestion below!

@nickytonline nickytonline changed the title feat: update to official Netlify Remix template feat: create official Netlify Remix template Feb 24, 2023
taty2010
taty2010 previously approved these changes Feb 24, 2023
Copy link

@taty2010 taty2010 left a comment

Choose a reason for hiding this comment

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

👏🏾 templates are working as expected on my end.

sarahetter
sarahetter previously approved these changes Feb 24, 2023
Copy link

@sarahetter sarahetter left a comment

Choose a reason for hiding this comment

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

Templates work, code LGTM! :shipit:

Co-authored-by: Stephanie <52582720+stephmarie17@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update template to reflect the official Netlify Edge Functions adapter and runtime
5 participants