From 821f7bfdc57c439dbb1d6ac170d58e3d02076ef6 Mon Sep 17 00:00:00 2001 From: morrys Date: Tue, 5 Oct 2021 12:17:55 +0200 Subject: [PATCH 1/3] added replace-in-file --- package-lock.json | 155 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 +- replace.config.js | 5 ++ 3 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 replace.config.js diff --git a/package-lock.json b/package-lock.json index 57f4e20e..1432273d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5998,6 +5998,12 @@ "es6-promise": "^4.0.3" } }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -12127,6 +12133,155 @@ "is-finite": "^1.0.0" } }, + "replace-in-file": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/replace-in-file/-/replace-in-file-6.2.0.tgz", + "integrity": "sha512-Im2AF9G/qgkYneOc9QwWwUS/efyyonTUBvzXS2VXuxPawE5yQIjT/e6x4CTijO0Quq48lfAujuo+S89RR2TP2Q==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "glob": "^7.1.6", + "yargs": "^16.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true + } + } + }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", diff --git a/package.json b/package.json index a2ac9575..9f252508 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "scripts": { "clean": "rimraf lib", - "compile": "npm run clean && tsc && tsc --project tsconfig.esm.json && npm run build:js && npm run rollup", + "compile": "npm run clean && tsc && tsc --project tsconfig.esm.json && npm run build:js && npm run build:replace && npm run rollup", "rollup": "rollup -c", "build": "npm run compile && npm run test", "test": "cross-env NODE_ENV=test jest --coverage", @@ -31,7 +31,8 @@ "format:ci": "prettier --list-different \"src/**/*.{j,t}s*\"", "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx", "prepublishOnly": "npm run build", - "build:js": "babel lib --out-dir lib --extensions \".js,.jsx\" && babel lib/es --out-dir lib/es --extensions \".js,.jsx\"" + "build:js": "babel lib --out-dir lib --extensions \".js,.jsx\" && babel lib/es --out-dir lib/es --extensions \".js,.jsx\"", + "build:replace": "replace-in-file --configFile=replace.config.js" }, "dependencies": { "@restart/hooks": "^0.3.1", @@ -58,6 +59,7 @@ "@types/relay-runtime": "10.1.2", "@typescript-eslint/eslint-plugin": "2.25.0", "@typescript-eslint/parser": "2.25.0", + "replace-in-file": "6.2.0", "cross-env": "^7.0.2", "eslint": "6.8.0", "eslint-config-prettier": "6.10.1", diff --git a/replace.config.js b/replace.config.js new file mode 100644 index 00000000..0918326b --- /dev/null +++ b/replace.config.js @@ -0,0 +1,5 @@ +module.exports = { + files: 'lib/**/*.*', + from: /import \* as /g, + to: 'import ', +}; From 8f482e3a9d546752cfb7cafefa7398aaf9e2657d Mon Sep 17 00:00:00 2001 From: morrys Date: Tue, 5 Oct 2021 12:18:09 +0200 Subject: [PATCH 2/3] update webpack in todo example --- examples/relay-hook-example/todo/package.json | 2 +- examples/relay-hook-example/todo/server.js | 75 ++++++++++--------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/examples/relay-hook-example/todo/package.json b/examples/relay-hook-example/todo/package.json index ebd46102..bf7bb8cc 100644 --- a/examples/relay-hook-example/todo/package.json +++ b/examples/relay-hook-example/todo/package.json @@ -48,7 +48,7 @@ "flow-typed": "^2.5.1", "prettier": "^1.16.4", "relay-compiler": "11.0.2", - "webpack": "^4.29.6", + "webpack": "^5.56.1", "webpack-dev-server": "^3.2.1" }, "prettier": { diff --git a/examples/relay-hook-example/todo/server.js b/examples/relay-hook-example/todo/server.js index cce81832..0176c866 100644 --- a/examples/relay-hook-example/todo/server.js +++ b/examples/relay-hook-example/todo/server.js @@ -17,10 +17,10 @@ import graphQLHTTP from 'express-graphql'; import path from 'path'; import webpack from 'webpack'; import WebpackDevServer from 'webpack-dev-server'; -import {schema} from './data/schema'; +import { schema } from './data/schema'; import { renderToString } from 'react-dom/server'; -import App from './js/app' -import html from './html' +import App from './js/app'; +import html from './html'; const APP_PORT: number = 3000; @@ -28,29 +28,32 @@ const APP_PORT: number = 3000; // Calling webpack() without a callback as 2nd property returns a Compiler object. // The libdefs don't like it, but it's fine. $FlowFixMe https://webpack.js.org/api/node/ const compiler: webpack.Compiler = webpack({ - mode: 'development', - entry: ['whatwg-fetch', path.resolve(__dirname, 'js', 'index.js')], - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - }, - }, - ], - }, - output: { - filename: 'app.js', - path: '/', - }, + mode: 'development', + entry: ['whatwg-fetch', path.resolve(__dirname, 'js', 'index.js')], + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + }, + }, + ], + }, + output: { + filename: 'app.js', + path: '/', + }, + resolve: { + preferRelative: true, + }, }); const app: WebpackDevServer = new WebpackDevServer(compiler, { - contentBase: '/public/', - publicPath: '/js/', - stats: {colors: true}, + contentBase: '/public/', + publicPath: '/js/', + stats: { colors: true }, }); // Serve static resources @@ -58,24 +61,24 @@ app.use('/public', express.static(path.resolve(__dirname, 'public'))); // Setup GraphQL endpoint app.use( - '/graphql', - graphQLHTTP({ - schema: schema, - pretty: true, - }), + '/graphql', + graphQLHTTP({ + schema: schema, + pretty: true, + }), ); app.use('/', async (req, res) => { - const appString = renderToString( App ); + const appString = renderToString(App); - res.send(html({ - body: appString, - title: 'Relay • TodoMVC SSR' - })); + res.send( + html({ + body: appString, + title: 'Relay • TodoMVC SSR', + }), + ); }); - - app.listen(APP_PORT, () => { - console.log(`App is now running on http://localhost:${APP_PORT}`); + console.log(`App is now running on http://localhost:${APP_PORT}`); }); From 4676c53e36e63ef997b693e5821ab33ae2cf07db Mon Sep 17 00:00:00 2001 From: morrys Date: Thu, 14 Oct 2021 12:17:22 +0200 Subject: [PATCH 3/3] version 5.0.1 --- examples/relay-hook-example/cra/package.json | 2 +- examples/relay-hook-example/pagination-nextjs-ssr/package.json | 2 +- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/relay-hook-example/cra/package.json b/examples/relay-hook-example/cra/package.json index 823fd2e5..900ba2b4 100644 --- a/examples/relay-hook-example/cra/package.json +++ b/examples/relay-hook-example/cra/package.json @@ -12,7 +12,7 @@ "react-dom": "^16.13.1", "react-scripts": "3.4.1", "relay-compiler": "^11.0.2", - "relay-hooks": "5.0.0", + "relay-hooks": "5.0.1", "relay-runtime": "11.0.2" }, "devDependencies": { diff --git a/examples/relay-hook-example/pagination-nextjs-ssr/package.json b/examples/relay-hook-example/pagination-nextjs-ssr/package.json index ec5bcb0f..df860a2a 100644 --- a/examples/relay-hook-example/pagination-nextjs-ssr/package.json +++ b/examples/relay-hook-example/pagination-nextjs-ssr/package.json @@ -26,7 +26,7 @@ "prop-types": "^15.7.2", "react": "^17.0.1", "react-dom": "^17.0.1", - "relay-hooks": "5.0.0", + "relay-hooks": "5.0.1", "relay-runtime": "11.0.2", "whatwg-fetch": "3.0.0", "react-infinite-scroller": "1.2.4" diff --git a/package-lock.json b/package-lock.json index 1432273d..69253fe4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "relay-hooks", - "version": "5.0.0", + "version": "5.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9f252508..2b65ac1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "relay-hooks", - "version": "5.0.0", + "version": "5.0.1", "keywords": [ "graphql", "relay",