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
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci-bun-loaders.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Continuous Integration - Bun (Loaders)

on: [pull_request]


jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Install Bun
uses: oven-sh/setup-bun@v2

# still using Yarn since we specifically rely on Yarn workspaces
- name: Install Dependencies
run: yarn install --frozen-lockfile && yarn lerna bootstrap

- name: Test
run: bun run --bun test:bun:loaders

- name: Build
run: bun run --bun build
25 changes: 25 additions & 0 deletions .github/workflows/ci-bun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Continuous Integration - Bun
on:
pull_request:
branches: master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Install Bun
uses: oven-sh/setup-bun@v2

# still using Yarn since we specifically rely on Yarn workspaces
- name: Install Dependencies
run: yarn install --frozen-lockfile && yarn lerna bootstrap

- name: Test
run: bun run --bun test:bun

- name: Build
run: bun run --bun build
2 changes: 1 addition & 1 deletion .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
timeout: 90000
timeout: 540000
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
"test": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict NODE_NO_WARNINGS=1 c8 mocha --exclude \"./packages/**/test/cases/loaders-*/**\" \"./packages/**/**/*.spec.js\"",
"test:loaders": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict NODE_NO_WARNINGS=1 node --loader $(pwd)/test/test-loader.js ./node_modules/mocha/bin/mocha \"./packages/**/**/*.spec.js\"",
"test:loaders:win": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict NODE_NO_WARNINGS=1 node --loader file:\\\\%cd%\\test\\test-loader.js ./node_modules/mocha/bin/mocha --exclude \"./packages/init/test/cases/**\" \"./packages/**/**/*.spec.js\"",
"test:bun": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict NODE_NO_WARNINGS=1 mocha --timeout 540000 --exclude \"./packages/**/test/cases/loaders-*/**\" \"./packages/**/**/*.spec.js\"",
"test:tdd": "yarn test --watch",
"lint:js": "eslint \"*.js\" \"./packages/**/**/*.js\" \"./test/*.js\" \"./www/**/**/*.js\"",
"lint:ts": "eslint \"./packages/**/**/*.ts\"",
"lint:css": "stylelint \"./www/**/*.js\", \"./www/**/*.css\"",
"lint": "ls-lint && yarn lint:js && yarn lint:css"
},
"trustedDependencies": ["puppeteer"],
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/eslint-parser": "^7.24.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/layout-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable complexity */
import fs from 'fs/promises';
import htmlparser from 'node-html-parser';
import * as htmlparser from 'node-html-parser';
import { checkResourceExists } from './resource-utils.js';
import { Worker } from 'worker_threads';
import { asyncFilter } from './async-utils.js';
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/lib/resource-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs/promises';
import { hashString } from './hashing-utils.js';
import { getResolvedHrefFromPathnameShortcut } from '../lib/node-modules-utils.js';
import htmlparser from 'node-html-parser';
import * as htmlparser from 'node-html-parser';
import { asyncMap } from './async-utils.js';

async function modelResource(context, type, src = undefined, contents = undefined, optimizationAttr = undefined, rawAttributes = undefined) {
Expand Down Expand Up @@ -42,7 +42,7 @@
const statusText = source.statusText || destination.statusText;

source.headers.forEach((value, key) => {
// TODO better way to handle Response automatically setting content-type

Check warning on line 45 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO better way to handle Response...'

Check warning on line 45 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO better way to handle Response...'

Check warning on line 45 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO better way to handle Response...'

Check warning on line 45 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO better way to handle Response...'
// https://github.com/ProjectEvergreen/greenwood/issues/1049
const isDefaultHeader = key.toLowerCase() === 'content-type' && value === 'text/plain;charset=UTF-8';

Expand Down Expand Up @@ -78,6 +78,10 @@
}

async function checkResourceExists(url) {
if (url.pathname === '/') {
return false;
}

try {
await fs.access(url);
return true;
Expand Down Expand Up @@ -173,7 +177,7 @@
return url !== '' && !url.startsWith('http') && !url.startsWith('//');
}

// TODO handle full request

Check warning on line 180 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO handle full request'

Check warning on line 180 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO handle full request'

Check warning on line 180 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected 'todo' comment: 'TODO handle full request'

Check warning on line 180 in packages/cli/src/lib/resource-utils.js

View workflow job for this annotation

GitHub Actions / build (18)

Unexpected ' TODO' comment: 'TODO handle full request'
// https://github.com/ProjectEvergreen/greenwood/discussions/1146
function transformKoaRequestIntoStandardRequest(url, request) {
const { body, method, header } = request;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/plugins/resource/plugin-standard-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getUserScripts, getPageLayout, getAppLayout } from '../../lib/layout-ut
import { requestAsObject } from '../../lib/resource-utils.js';
import unified from 'unified';
import { Worker } from 'worker_threads';
import htmlparser from 'node-html-parser';
import * as htmlparser from 'node-html-parser';

class StandardHtmlResource extends ResourceInterface {
constructor(compilation, options) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-css-modules/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/
import fs from 'fs';
import htmlparser from 'node-html-parser';
import * as htmlparser from 'node-html-parser';
import { parse, walk } from 'css-tree';
import { ResourceInterface } from '@greenwood/cli/src/lib/resource-interface.js';
import * as acornWalk from 'acorn-walk';
Expand Down
Loading