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

Enhancement/issue 946 decouple build and serve commands from workspace #1079

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Mar 7, 2023

Related Issue

resolves #946

Summary of Changes

  1. Bundle API and SSR routes and created a manifest.json
  2. "Hydrate" serve command + hybrid server using graph.json and manifest.json to manage serving API routes and SSR pages
  3. Decouple serve command from running build and serve (greenwood serve now requires that a greenwood build has been run)
  4. Created a lib/template-utils.js and added (Greenwood's) templateDir to context

TODO

  1. Flesh out remaining templating use cases (should get all tests passing)
  2. Decouple serve command from bundle lifecycle and add test case in /cli/src/index.js and update specs
  3. Testing
    • Static Router spec failing / conflicting (seems to be because of needing to scaffold lib/router.js)
    • serve pre-requisite on build (warning spec)
    • Test output files for SSR and manifest.json (save for dedicated issue on consolidating build output?)
  4. Address issue with WCC and wrapping tags (related to wcc wrapping based on any definition it finds now that we are bundling) - opt out of top level wrapping entry tag name when using renderToString wcc#114
    <x-card>
      <h1>List of Artists: <span id="count">11</span></h1>
    
      <x-card name="Analog">
        <h1>Hello Analog</h1>
    
        <img slot="image" src="//d34k5cjnk2rcze.cloudfront.net/images/artists/analog.jpg" alt="PIcture of Analog">
      </x-card>
    
      <x-card name="Electro Calrissian">
        <h1>Hello Electro Calrissian</h1>
        
        <img slot="image" src="//d34k5cjnk2rcze.cloudfront.net/images/artists/electro-calrissian.jpg" alt="PIcture of Electro Calrissian">
      </x-card>
    
      ...
    
    </x-card>
  5. Consolidate template-utils.js / align with standard HTML plugin and leverage a consistent templatesDir context
  6. Documentation (build + serve commands)
    • Need node_modules
    • need greenwood.config.js
    • need output directory
  7. clean up console logs / track TODOs
  8. Context plugins in SSR routes?
  9. "vendor" new rollup plugins (nice to have)
    • json
    • import URL

Thoughts / Questions / Enhancements Tracking

  1. Should probably consider putting resources and other compilation related information into manifest.json and document as build output with tests. (could do this as a guide?) - Static and Serverless Hosting Runtime Adapters #1008
  2. better way to DI compilation into SSR pages instead of through handler? (probably include as part of serverless work) - Static and Serverless Hosting Runtime Adapters #1008
  3. Does it make sense to ditch Workers? Causing a bit of overhead here and maybe could be an option instead (if using Node?) 🤔 (see similar thoughts raised in performance benchmarking / optimizing Greenwood #970) - evaluate (remove) use of Workers for SSR and prerendering #1088
    • To the above, if we ditch workers, we might not have to do the whole generated code output like we're doing to split the page code from the worker code?
  4. Should API and SSR pages have chunks, or be entirely self contained (per Static and Serverless Hosting Runtime Adapters #1008 ) and also minified? - Static and Serverless Hosting Runtime Adapters #1008
  5. Should probably upgrade Rollup (v3?) and ours plugins? - upgrade Rollup and all plugins to 3.x #1087
  6. Added more Rollup plugins would be good to figure out this, or maybe consider esbuild if it has all this out of the box and is more "web api" friendly? Related to Rollup is a leaky abstraction distraction - upgrade Rollup and all plugins to 3.x #1087

@thescientist13 thescientist13 added question Further information is requested RFC Proposal and changes to workflows, architecture, APIs, etc CLI SSR feature New feature or request v0.28.0 labels Mar 7, 2023
@thescientist13 thescientist13 self-assigned this Mar 7, 2023
@thescientist13 thescientist13 changed the title Enhancement/issue 946 decouple serve command from workspace Enhancement/issue 946 decouple build and serve commands from workspace Mar 7, 2023
@@ -24,6 +24,9 @@
"access": "public"
},
"dependencies": {
"@web/rollup-plugin-import-meta-assets": "^1.0.0",
"@rollup/plugin-commonjs": "^21.0.0",
"@rollup/plugin-json": "^4.1.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

not super happy about this, but I think I can at least handle two of these on my own if I had to (json and import meta assets). But for now it works. 🤞

@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) and removed feature New feature or request labels Mar 7, 2023
@thescientist13 thescientist13 added the documentation Greenwood specific docs label Mar 26, 2023
@thescientist13 thescientist13 marked this pull request as ready for review March 27, 2023 00:54
@thescientist13 thescientist13 removed the question Further information is requested label Mar 27, 2023
@thescientist13 thescientist13 force-pushed the enhancement/issue-946-decouple-serve-command-from-workspace branch from 4f67e73 to b784db1 Compare April 1, 2023 19:11
@thescientist13 thescientist13 merged commit c09138d into release/0.28.0 Apr 1, 2023
@thescientist13 thescientist13 deleted the enhancement/issue-946-decouple-serve-command-from-workspace branch April 1, 2023 21:36
thescientist13 added a commit that referenced this pull request Apr 9, 2023
#1079)

* track APIs as part of compilation.manifest and leverage in API routes resource plugin

* API routes bundling

* pull API routes from manifest for serve command

* bundle SSR routes

* WCC bunding in API routes

* create copy plugin for manifest.json

* refactor SSR route bundling

* most templating functions working for SSR templating

* fill static and SSR templating working with optimizations

* fix SSR title rendering

* add support for getUserScripts in SSR

* hacky work around to get static router + SSR spec working

* enable spec

* decouple build command from serve command

* add build output as pre-requisite to runngin serve command

* document new greenwood serve behavior

* refactor SSR compilation context bundle output

* refactor plugin-standard-html to use template utils

* create custom json transformation transformer to handle escodegen

* create custom json transformation transformer to handle escodegen

* support context plugins in SSR templating

* TODO tracking and console log cleanup

* upgrade latest wcc with HTML wrapping tag disabled

* fix linting

* fix path references

* normalize SSR static router hack pathnames for windows

* normalize SSR static router hack pathnames for windows
thescientist13 added a commit that referenced this pull request Apr 9, 2023
#1079)

* track APIs as part of compilation.manifest and leverage in API routes resource plugin

* API routes bundling

* pull API routes from manifest for serve command

* bundle SSR routes

* WCC bunding in API routes

* create copy plugin for manifest.json

* refactor SSR route bundling

* most templating functions working for SSR templating

* fill static and SSR templating working with optimizations

* fix SSR title rendering

* add support for getUserScripts in SSR

* hacky work around to get static router + SSR spec working

* enable spec

* decouple build command from serve command

* add build output as pre-requisite to runngin serve command

* document new greenwood serve behavior

* refactor SSR compilation context bundle output

* refactor plugin-standard-html to use template utils

* create custom json transformation transformer to handle escodegen

* create custom json transformation transformer to handle escodegen

* support context plugins in SSR templating

* TODO tracking and console log cleanup

* upgrade latest wcc with HTML wrapping tag disabled

* fix linting

* fix path references

* normalize SSR static router hack pathnames for windows

* normalize SSR static router hack pathnames for windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking CLI documentation Greenwood specific docs enhancement Improve something existing (e.g. no docs, new APIs, etc) RFC Proposal and changes to workflows, architecture, APIs, etc SSR
Projects
None yet
1 participant