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

feature/issue 953 support for Bun #1308

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented Nov 9, 2024

Related Issue

related to #1323

See a userland example here - https://github.com/thescientist13/greenwood-bun

Summary of Changes

  1. Add GitHub Actions for Bun
  2. Had to alter import for node-html-parser
       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
      
  3. Had to check for an unexpected URL coming from Rollup
      {
         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],
         },
       }
      

Documentation

  1. Add a PR to the website (home page, hosting, etc) (assuming all actions pass)
    • callout needing trustedDependencies to support postinstall scripts with Bun, like for the puppeteer plugin
    • make sure to run bun with --bun flag for NPM scripts

TODO

  1. Actually use bun for npm scripts / github actions 🤦‍♂️
  2. Mocha test cases seem to run foreeveer, since failing tests cases pass when run individually - Investigate why mocha is very slow oven-sh/bun#13087
         3137 passing (42m)
         85 pending
         44 failing
      
    - actually, locally (macOS) with the a new timeout, seems to work much better, but still slow on CI (Linux)?
       3220 passing (5m)
       85 pending
      
  3. Validate / support custom loaders equivalent - https://bun.sh/docs/runtime/plugins
  4. GraphQL failing
       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)
      
  5. Bun upstreams / repos
    • node-html-parser import
    • Rollup bundle issue on URL

@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
Copy link
Member Author

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

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

Doh, I spoke too soon :/

I forgot that our NPM scripts still call out to node lol, so of course when I removed that and run bun run build it fails lol

Initializing active content...
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".svg" for /Users/owenbuckley/Workspace/project-evergreen/www.greenwoodjs.dev/src/assets/discord.svg
    at new NodeError (node:internal/errors:405:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:136:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:182:36)
    at defaultLoad (node:internal/modules/esm/load:101:20)
    at ModuleLoader.load (node:internal/modules/esm/loader:417:13)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:288:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at #createModuleJob (node:internal/modules/esm/loader:312:17)
    at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:265:34)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:251:17) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

So seems like some sort of adapter would be needed for this then. 😞

I guess we would have to implement a plugin somehow?
https://bun.sh/docs/bundler/plugins

@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
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 question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bun runtime support
1 participant