Skip to content

Commit

Permalink
enhancement/issue 1220 adopt NodeJS register API for custom loaders (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 authored Jan 12, 2025
1 parent 287b993 commit 33da5e2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-loaders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
node: [20, 22]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Install Chromium Library Dependencies
run: |
sh ./.github/workflows/chromium-lib-install.sh
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Installing project dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-win-loaders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
node: [20]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Installing project dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
node: [20]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Installing project dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
node: [20, 22]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Install Chromium Library Dependencies
run: |
sh ./.github/workflows/chromium-lib-install.sh
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Installing project dependencies
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"serve": "node . serve",
"develop": "node . develop",
"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:loaders": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict NODE_NO_WARNINGS=1 node --import $(pwd)/test/test-register.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 --import file:\\\\%cd%\\test\\test-register.js ./node_modules/mocha/bin/mocha --exclude \"./packages/init/test/cases/**\" \"./packages/**/**/*.spec.js\"",
"test:tdd": "yarn test --watch",
"lint:js": "eslint \"*.js\" \"./packages/**/**/*.js\" \"./test/*.js\" \"./www/**/**/*.js\"",
"lint:ts": "eslint \"./packages/**/**/*.ts\"",
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
"node": "^18.20.5 || ^20.10.0 || ^22.12.0"
},
"main": "./src/index.js",
"exports": {
".": "./src/index.js",
"./register": "./src/register.js",
"./src/*": "./src/*"
},
"bin": {
"greenwood": "./src/index.js"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { register } from 'node:module';

register('./loader.js', import.meta.url);
3 changes: 3 additions & 0 deletions test/test-register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { register } from 'node:module';

register('./test-loader.js', import.meta.url);

0 comments on commit 33da5e2

Please sign in to comment.