Skip to content

Conversation

@thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Nov 9, 2024

Related Issue

related to #1323

See example / demo repo here

Summary of Changes

  1. Add GitHub Actions for Bun
  2. Made slight tweaks per results uncovered during testing

Documentation

  1. Add a PR to the website (home page, hosting, etc) (assuming all actions pass)
  2. document trusted deps in puppeteer plugin README

TODO

  1. Actually use bun for npm scripts / github actions 🤦‍♂️
  2. Upgrade to latest node-html-parser (standalone issue / PR) - upgrade to use latest version of node-html-parser #1428
  3. Upgrade to apollo/server v4 (standalone issue / PR) - enhancement(plugins): #1429 upgrade GraphQL plugin to apollo v4 #1593
  4. test cases are failing
  5. Issues with some test reject cases
  6. import map is returning different results (does it matter too much if it still works?)
  7. PostCSS being annoying - feat(runtimes): #1323 support for Bun #1308 (comment)
  8. tests are generally flaky, even locally
  9. SSR broken with greenwood serve (needs WCC upstream) - bug: patch support for greenwood serve with wc-compiler and bun thescientist13/www.toosh.pet#10
  10. (Blocked) Validate / support custom loaders equivalent (or only consider it experimental?) - Bun runtime support #1323 (comment)
  11. Init installer option (at least for package manager)
  12. update GitHub Actions repo settings
  13. bug(cli): #1323 refine serving logic for node modules plugin #1577
  14. Open a discussion for open items / experimental caveats
    • import map generation count is slightly off

Upstreams / Issues

  1. (Bun) Decorators not supported - support typescript@5 decorator oven-sh/bun#4122 (comment)

  2. (Bun) Plugins are not supported in Workers - Worker does not load preload from bunfig.toml oven-sh/bun#12608 (comment)

  3. Give feedback on Investigate why mocha is very slow oven-sh/bun#13087

  4. node-html-parser import - giving this one a pass for now - https://github.com/thescientist13/bun-node-compat-tests?tab=readme-ov-file#node-html-parser

    Details
       TypeError: htmlparser.parse is not a function. (In 'htmlparser.parse(html, {
         script: !0,
         style: !0
       })', 'htmlparser.parse' is undefined)
           at /Users/owenbuckley/Workspace/github/greenwood-bun/node_modules/@greenwood/cli/src/lib/resource-utils.js:116:27
           at trackResourcesForRoute (/Users/owenbuckley/Workspace/github/greenwood-bun/node_modules/@greenwood/cli/src/lib/resource-utils.js:114:39)
           at /Users/owenbuckley/Workspace/github/greenwood-bun/node_modules/@greenwood/cli/src/lifecycles/prerender.js:168:11
       
  5. Had to check for an unexpected URL coming from Rollup - can't reproduce?

    Details
        {
           id: "\u0000commonjsHelpers.js",
           idUrl: URL {
             href: "file://commonjshelpers.js/",
             origin: "null",
             protocol: "file:",
             username: "",
             password: "",
             host: "commonjshelpers.js",
             hostname: "commonjshelpers.js",
             port: "",
             pathname: "/",
             hash: "",
             search: "",
             searchParams: URLSearchParams {},
             toJSON: [Function: toJSON],
             toString: [Function: toString],
           },
         }
       
  6. Lit SSR - can not reproduce

    Details
         building from local sources...
         200 |   #onClose(e) {
         201 |     this.#onExitPromise = e.code, this.emit("exit", e.code);
         202 |   }
         203 |   #onError(event) {
         204 |     let error = event?.error;
         205 |       error = new Error(event.message, { cause: event });
                             ^
         error: 1 | /**
         2 |  * @license
         3 |  * Copyright 2017 Google LLC
         4 |  * SPDX-License-Identifier: BSD-3-Clause
         5 |  */
         6 | const t=globalThis,i=t.trustedTypes,s=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+h,n=`<${o}>`,r=void 0===t.document?{createTreeWalker:()=>({})}:document,l=()=>r.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=y(2),b=y(3),w=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r.createTreeWalker(r,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s?s.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"":3===i?"":"",c=f;for(let i=0;i TypeError: r.createTreeWalker is not a function. (In 'r.createTreeWalker(r, 129)', 'r.createTreeWalker' is undefined)
           at /Users/owenbuckley/Workspace/github/greenwood-lit-ssr/node_modules/lit-html/node/lit-html.js:6:750
     
           at #onError (node:worker_threads:205:15)
     
     Bun v1.2.2 (macOS arm64)
     error: script "build" exited with code 1
    
  7. GraphQL failing - looks like we just need to upgrade to @apollo/server v4 - https://github.com/thescientist13/bun-node-compat-tests?tab=readme-ov-file#%EF%B8%8F-apollo-graphql-server-playground

    Details
       OPTIONS - /graphql failed
       30 |         }
       31 |         var connectionHandler = (function (socket, request) {
       32 |             socket.upgradeReq = request;
       33 |             if (socket.protocol === undefined ||
       34 |                 (socket.protocol.indexOf(protocol_1.GRAPHQL_WS) === -1 && socket.protocol.indexOf(protocol_1.GRAPHQL_SUBSCRIPTIONS) === -1)) {
       35 |                 socket.close(1002);
                                   ^
       TypeError: socket.close is not a function. (In 'socket.close(1002)', 'socket.close' is undefined)
             at connectionHandler (/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/subscriptions-transport-ws/dist/server.js:35:24)
       
  8. bug(cli): #1323 refine serving logic for node modules plugin #1577

  9. Mocha test cases seem to run foreveeeeeer, since failing tests cases pass when run individually - Investigate why mocha is very slow oven-sh/bun#13087

    • seems fine (now)

@thescientist13 thescientist13 added enhancement Improve something existing (e.g. no docs, new APIs, etc) documentation Greenwood specific docs CLI labels Nov 9, 2024
@thescientist13 thescientist13 added this to the 1.0 milestone Nov 9, 2024
@thescientist13 thescientist13 changed the title add github actions for bun feature/issue 953 validate support for Bun Nov 9, 2024
@thescientist13 thescientist13 added feature New feature or request question Further information is requested and removed enhancement Improve something existing (e.g. no docs, new APIs, etc) labels Nov 9, 2024
thescientist13

This comment was marked as duplicate.

@thescientist13 thescientist13 changed the title feature/issue 953 validate support for Bun feature/issue 953 support for Bun Nov 11, 2024
@thescientist13 thescientist13 mentioned this pull request Nov 25, 2024
40 tasks
@thescientist13 thescientist13 linked an issue Nov 28, 2024 that may be closed by this pull request
@thescientist13 thescientist13 removed this from the 1.0 milestone Nov 28, 2024
@thescientist13 thescientist13 force-pushed the feature/issue-953-bun-compat branch from d11db6b to 2f55bb7 Compare January 2, 2025 17:54
@thescientist13 thescientist13 self-assigned this Jan 2, 2025
@thescientist13 thescientist13 force-pushed the feature/issue-953-bun-compat branch from fa3acc0 to 41d563c Compare February 21, 2025 22:37
@thescientist13 thescientist13 changed the title feature/issue 953 support for Bun feature/issue 1323 support for Bun Feb 22, 2025
@thescientist13 thescientist13 changed the title feature/issue 1323 support for Bun feat(cli): #1323 support for Bun Oct 4, 2025
@thescientist13
Copy link
Member Author

Interesting, running a test with Bun gets this order of pages when crawling the pages directory

  Build Greenwood With: 
    Prerender Configuration turned on using Content As Data collections
-------------------------------------------------------
Welcome to Greenwood (v0.33.3) ♻️
-------------------------------------------------------
Running Greenwood with the build command.
Initializing project config
Initializing project workspace contexts
Generating graph of workspace files...
building from local sources...
building from external sources...
pages to generate 
 /
 /toc/
 /blog/
 /blog/second-post/
 /blog/first-post/
 /external/
Initializing active content...

While Node gives them top down

  Build Greenwood With: 
    Prerender Configuration turned on using Content As Data collections
-------------------------------------------------------
Welcome to Greenwood (v0.33.3) ♻️
-------------------------------------------------------
Running Greenwood with the build command.
Initializing project config
Initializing project workspace contexts
Generating graph of workspace files...
building from local sources...
building from external sources...
pages to generate 
 /blog/first-post/
 /blog/
 /blog/second-post/
 /
 /toc/
 /external/
Initializing active content...

This causes some test cases to fail since they assume a specific order of content as data

See oven-sh/bun#10112 and thescientist13/greenwood-starter-presentation#49

@thescientist13
Copy link
Member Author

For some other stuff related to tests

1) Develop Greenwood With: 
     Default Configuration for CSS Modules
       index.html with expected CSS and SSR contents
         Header component with CSS Modules
           CSS module should be processed as ESM
             "before all" hook for "the served content should be untouched":
   Error: scan: invalid `cwd`, not a string

For this error, cwd for fs.glob needed to be a string
Screenshot 2025-10-04 at 7 50 38 PM

@thescientist13
Copy link
Member Author

thescientist13 commented Oct 5, 2025

For init, was getting this test failure when running the Yarn installer

➜  greenwood git:(feature/issue-953-bun-compat) ✗ bun run --bun test:bun
$ cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict NODE_NO_WARNINGS=1 mocha --timeout 360000 --exclude "./packages/**/test/cases/loaders-*/**" "./packages/**/**/*.spec.js"


  Initialize a new Greenwood project: 
    Scaffolding a new project with dependencies installed through Yarn
-------------------------------------------------------
Initialize a Greenwood Project (v0.33.3) ♻️
-------------------------------------------------------
creating output directory => my-app
copying project files to =>  /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/init/test/cases/init.options.install-yarn/my-app/
setting up package.json...
creating a .gitignore file...
installing dependencies using => yarn...
yarn install v1.22.22
warning package.json: No license field
info No lockfile found.
warning [email protected]: No license field
[1/4] 🔍  Resolving packages...
error Error: https://registry.yarnpkg.com/@greenwood%2fcli: SSL Error: https://registry.yarnpkg.com/@greenwood%2fcli does not support SSL
    at <anonymous> (/Users/owenbuckley/.nvm/versions/node/v22.18.0/lib/node_modules/yarn/lib/cli.js:142154:27)
    at emit (node:events:95:22)
    at <anonymous> (node:_http_client:232:45)
    at processTicksAndRejections (native:7:39)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Had to run this command

yarn config set strict-ssl false

@thescientist13
Copy link
Member Author

Getting some issues from the develop related test cases

 101 passing (6s)
  7 failing

  1) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command with source map specific behavior
           should return the correct content type:

      expected 'text/javascript' to equal 'application/json'
      + expected - actual

      -text/javascript
      +application/json
      
  Error
      at unknown
      at <anonymous> (packages/cli/test/cases/develop.default/develop.default.spec.js:539:57)

  2) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command with POST API specific behaviors for JSON
           should return a 200 status:

      expected 500 to equal 200
      + expected - actual

      -500
      +200
      
  Error
      at unknown
      at <anonymous> (packages/cli/test/cases/develop.default/develop.default.spec.js:802:36)

  3) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command with POST API specific behaviors for JSON
           should return the expected response message:
     TypeError: null is not an object (evaluating 'data.message')
      at <anonymous> (packages/cli/test/cases/develop.default/develop.default.spec.js:806:16)

  4) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command with POST API specific behaviors for JSON
           should return the expected content type header:

      expected 'text/plain; charset=utf-8' to equal 'application/json'
      + expected - actual

      -text/plain; charset=utf-8
      +application/json
      
  Error
      at unknown
      at <anonymous> (packages/cli/test/cases/develop.default/develop.default.spec.js:810:57)

  5) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command with POST API specific behaviors for JSON
           should return the secret header in the response:
     expected null to equal '1234'
  Error
      at unknown
      at <anonymous> (packages/cli/test/cases/develop.default/develop.default.spec.js:814:53)

  6) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command with POST API specific behaviors for FormData
           "before all" hook for "should return a 200 status":
     Unable to connect. Is the computer able to access the url?
  

  7) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command nested API specific behaviors
           "before all" hook for "should return a 200 status":
     Unable to connect. Is the computer able to access the url?

@thescientist13 thescientist13 force-pushed the feature/issue-953-bun-compat branch from 81ea23a to 7d90290 Compare October 5, 2025 00:06
@thescientist13 thescientist13 added the Runtimes Tasks related to supporting runtimes like Deno, Bun, etc label Oct 18, 2025
@thescientist13 thescientist13 changed the title feat(cli): #1323 support for Bun feat(runtimes): #1323 support for Bun Oct 18, 2025
@thescientist13
Copy link
Member Author

Hmm, seems like we're getting a little trouble from PostCSS...

****************************************************************************
11 | 
12 | async function getConfig(compilation, extendConfig = false) {
13 |   const { projectDirectory } = compilation.context;
14 |   const configFile = "postcss.config";
15 |   // @ts-expect-error see https://github.com/microsoft/TypeScript/issues/42866
16 |   const defaultConfig = (await import(new URL(`./${configFile}.js`, import.meta.url)))?.default;
                                                                                        ^
ReferenceError: Cannot access 'default' before initialization.
      at getConfig (/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/plugin-postcss/src/index.js:16:84)
      at preIntercept (/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/plugin-postcss/src/index.js:51:26)
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:166:22
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:162:27
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:162:27
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:162:27
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:161:40
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:128:4
      at /Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lifecycles/serve.js:74:9
      at processTicksAndRejections (native:7:39)

and so of course running the local website the styles are broken
Screenshot 2025-10-18 at 7 04 15 PM

@thescientist13

This comment was marked as resolved.

@thescientist13
Copy link
Member Author

thescientist13 commented Oct 18, 2025

Perhaps attributable to different implementations around fs.glob but getting slightly different results for the import map count

  1) Develop Greenwood With: 
       Default Greenwood Configuration and Workspace
         Develop command specific HTML behaviors
           should return an import map shim <script> in the <head> of the document:

      expected 15125 to equal 15154
      + expected - actual

      -15125
      +15154
      
  Error
      at unknown
      at <anonymous> (packages/cli/test/cases/develop.default/develop.default.spec.js:134:39)

@thescientist13 thescientist13 force-pushed the feature/issue-953-bun-compat branch from 3ec9b8e to 5599db5 Compare October 19, 2025 00:02
@thescientist13 thescientist13 force-pushed the feature/issue-953-bun-compat branch from 3f41a25 to af6372e Compare November 8, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI documentation Greenwood specific docs feature New feature or request Init needs upstream question Further information is requested Runtimes Tasks related to supporting runtimes like Deno, Bun, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bun runtime support

2 participants