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: add layer0 preset #39

Closed
wants to merge 15 commits into from
Closed

feat: add layer0 preset #39

wants to merge 15 commits into from

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Apr 6, 2022

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Extracterd from @layer0/nuxt3. Currently based on node presrt and generates additional .output/server/prod.cjs with layer0 format and CommonJS wrapper.

Try with:

  • Clone repo and follow contribution guide to setup
  • Switch to feat/layer0-preset branch
  • Build with NITRO_PRESET=layer0 yarn nitro build examples/hello-world and check examples/hello-world/.output

Questions:

  • What would be deploy and preview commands for this?
  • How we can detect running in Layer0 CI/CD to automatically enable preset? (see this. providers usually expose a distrinct environment variable)

/cc @tristanlee85

Future improvements:

Looking at routes.js, we can potentially auto genere this file from nitro route caching rules for edge-caching. I need more details how it works :)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@pi0 pi0 self-assigned this Apr 6, 2022
@pi0 pi0 marked this pull request as draft April 7, 2022 12:59
@pi0 pi0 mentioned this pull request Apr 8, 2022
6 tasks
@pi0 pi0 changed the title feat: add layer0 basic preset feat: add layer0 preset Apr 8, 2022
@tristanlee85
Copy link
Contributor

Questions:

  • What would be deploy and preview commands for this?
  • How we can detect running in Layer0 CI/CD to automatically enable preset? (see this. providers usually expose a distrinct environment variable)

/cc @tristanlee85

Deploy command: Since this will have been built already with Nitro, it can be deployed with layer0 deploy --skipFramework to skip the framework build.

Preview command: I assume you are just wanting to run the production build locally? If that is the case, the command would be layer0 run --production.

I did try this locally, but got hung up on some error that I've been trying to debug:

 nitro git:(feat/layer0-preset) NITRO_PRESET=layer0 yarn nitro build examples/hello-world
βœ” Generated public examples/hello-world/.output/public          nitro 13:41:39
start Building server...                                        nitro 13:41:39
start Writing server bundle...                                  nitro 13:41:39
βœ” Server built                                                  nitro 13:41:39
  β”œβ”€ examples/hello-world/.output/server/package.json (346 B) (200 B gzip)
  β”œβ”€ examples/hello-world/.output/server/index.mjs (10.6 kB) (3.52 kB gzip)
  └─ examples/hello-world/.output/server/chunks/hello.mjs (133 B) (123 B gzip)
Ξ£ Total size: 414 kB (105 kB gzip)
TypeError: input.replaceAll is not a function
    at rewriteRelativePaths (/Users/tristanlee/Projects/nitro/src/build.ts:156:18)
    at _build (/Users/tristanlee/Projects/nitro/src/build.ts:159:61)
    at async main (/Users/tristanlee/Projects/nitro/src/cli.ts:35:5)

@danielroe
Copy link
Member

@tristanlee85 That should be now resolved, by #42. (Or you can use node 16 until you upgrade.)

It's assumed these are already installed and not necessary as part of Nitro
@pi0
Copy link
Member Author

pi0 commented Apr 12, 2022

I'm moving layer0 preset for now to a POC repository to avoid conflicts with nitro changes and also trying deployment easier. https://github.com/unjs/nitro-poc-layer0

@pi0 pi0 closed this Apr 12, 2022
@pi0 pi0 deleted the feat/layer0-preset branch April 12, 2022 23:31
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.

None yet

3 participants