diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ef54801..c4e84da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: - name: Use Node.js LTS uses: actions/setup-node@v1 with: - node-version: '14.x' + node-version: '20.x' - uses: bahmutov/npm-install@v1 with: install-command: yarn --immutable diff --git a/.gitignore b/.gitignore index 2973189..fbbc3f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -lib +dist node_modules .nvmrc .nyc_output diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0cdda97..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: node_js -node_js: - - 'node' -env: - global: - - CHROME_BIN="chromium-browser" - - DISPLAY=:99.0 - - NODE_ENV=test -dist: trusty -cache: - directories: - - node_modules -before_install: - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16" - - sh -e /etc/init.d/xvfb start - - sleep 3 -branches: - only: - - master - - next diff --git a/Makefile b/Makefile index 89a885b..86e9a48 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,13 @@ install: package.json ## Install dependencies @$(PKG) install watch: ## continuously compile ES6 files to JS - NODE_ENV=development ./node_modules/.bin/webpack --watch + @yarn vite build --watch test: ## Launch unit tests - @NODE_ENV=test ./node_modules/.bin/jest + @NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest watch-test: ## Launch unit tests and watch for changes - @NODE_ENV=test ./node_modules/.bin/jest --watch + @NODE_ENV=test NODE_OPTIONS="$$NODE_OPTIONS --experimental-vm-modules" ./node_modules/.bin/jest --watch format: ## Format the source code @./node_modules/.bin/eslint --fix ./src @@ -25,4 +25,6 @@ run: ## Launch server with example data @node ./bin/json-graphql-server.js example/data.js build: ## Build production release - @NODE_ENV=production ./node_modules/.bin/webpack + @yarn vite build + @yarn vite build -c ./vite.config.node.js + @yarn vite build -c ./vite.config.umd.js diff --git a/README.md b/README.md index 09369a1..b2001fb 100644 --- a/README.md +++ b/README.md @@ -448,7 +448,7 @@ Then use the `jsonGraphqlExpress` express middleware: ```js import express from 'express'; -import jsonGraphqlExpress from 'json-graphql-server'; +import jsonGraphqlExpress from 'json-graphql-server/node'; const PORT = 3000; const app = express(); @@ -469,7 +469,7 @@ Useful when using XMLHttpRequest directly or libraries such as [axios](https://w Add a `script` tag referencing the library: ```html - + ``` It will expose the `JsonGraphqlServer` as a global object: diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index da13de5..0000000 --- a/babel.config.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = { - env: { - test: { - presets: [ - [ - '@babel/preset-env', - { - targets: { - node: 'current', - }, - }, - ], - ], - }, - development: { - presets: [ - [ - '@babel/preset-env', - { - modules: false, - }, - ], - ], - plugins: ['add-module-exports'], - }, - production: { - presets: [ - [ - '@babel/preset-env', - { - modules: false, - }, - ], - ], - plugins: ['add-module-exports'], - }, - }, -}; diff --git a/bin/json-graphql-server.js b/bin/json-graphql-server.cjs similarity index 93% rename from bin/json-graphql-server.js rename to bin/json-graphql-server.cjs index 46d59e7..70382e1 100755 --- a/bin/json-graphql-server.js +++ b/bin/json-graphql-server.cjs @@ -3,7 +3,7 @@ require('reify'); var path = require('path'); var express = require('express'); var cors = require('cors'); -var JsonGraphqlServer = require('../lib/json-graphql-server.node.min').default; +var JsonGraphqlServer = require('../dist/json-graphql-server-node').default; var dataFilePath = process.argv.length > 2 ? process.argv[2] : './data.json'; var data = require(path.join(process.cwd(), dataFilePath)); diff --git a/example/index.html b/example/index.html index 86c75c0..b54e7b3 100644 --- a/example/index.html +++ b/example/index.html @@ -5,7 +5,7 @@
- +