From 08ae16dead77e796aaee90742b914858dd33fe77 Mon Sep 17 00:00:00 2001 From: Nathaniel Tucker Date: Tue, 24 Dec 2024 19:11:18 +0000 Subject: [PATCH] internal: Use yarn pnp --- .changeset/yellow-seahorses-learn.md | 5 +++ .circleci/config.yml | 13 ++++---- .vscode/extensions.json | 3 +- .vscode/settings.json | 10 ++++-- .yarn/sdks/eslint/bin/eslint.js | 32 +++++++++++++++++++ .yarn/sdks/eslint/package.json | 27 ++++++++++++++++ .yarn/sdks/integrations.yml | 5 +++ .yarn/sdks/prettier/bin/prettier.cjs | 32 +++++++++++++++++++ .yarn/sdks/prettier/index.cjs | 32 +++++++++++++++++++ .yarn/sdks/prettier/package.json | 7 ++++ .yarn/sdks/typescript/bin/tsc | 32 +++++++++++++++++++ .yarn/sdks/typescript/bin/tsserver | 32 +++++++++++++++++++ .yarn/sdks/typescript/package.json | 10 ++++++ .yarnrc.yml | 3 +- examples/github-app/package-lock.json | 24 ++++++++++++++ examples/github-app/package.json | 2 ++ package.json | 3 +- packages/core/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 12 ++----- packages/endpoint/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 11 ++----- packages/graphql/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 11 ++----- packages/img/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 10 ++---- packages/normalizr/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 7 +--- packages/react/package.json | 5 +-- .../{rollup.config.js => rollup.config.mjs} | 12 ++----- packages/react/src/hooks/useCancelling.ts | 2 +- packages/rest/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 11 ++----- packages/ssr/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 11 ++----- packages/test/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 7 ++-- packages/use-enhanced-reducer/package.json | 3 +- .../{rollup.config.js => rollup.config.mjs} | 11 ++----- scripts/copywebsitetypes.sh | 2 +- .../globals.rollup.config.js | 2 +- scripts/rollup-plugins/index.js | 10 ++++++ scripts/rollup-plugins/package.json | 26 +++++++++++++++ scripts/{ => rollup-plugins}/rollup-utils.js | 0 yarn.lock | 27 ++++++++++++++++ 44 files changed, 367 insertions(+), 109 deletions(-) create mode 100644 .changeset/yellow-seahorses-learn.md create mode 100755 .yarn/sdks/eslint/bin/eslint.js create mode 100644 .yarn/sdks/eslint/package.json create mode 100644 .yarn/sdks/integrations.yml create mode 100755 .yarn/sdks/prettier/bin/prettier.cjs create mode 100644 .yarn/sdks/prettier/index.cjs create mode 100644 .yarn/sdks/prettier/package.json create mode 100755 .yarn/sdks/typescript/bin/tsc create mode 100755 .yarn/sdks/typescript/bin/tsserver create mode 100644 .yarn/sdks/typescript/package.json rename packages/core/{rollup.config.js => rollup.config.mjs} (81%) rename packages/endpoint/{rollup.config.js => rollup.config.mjs} (81%) rename packages/graphql/{rollup.config.js => rollup.config.mjs} (79%) rename packages/img/{rollup.config.js => rollup.config.mjs} (83%) rename packages/normalizr/{rollup.config.js => rollup.config.mjs} (89%) rename packages/react/{rollup.config.js => rollup.config.mjs} (86%) rename packages/rest/{rollup.config.js => rollup.config.mjs} (80%) rename packages/ssr/{rollup.config.js => rollup.config.mjs} (84%) rename packages/test/{rollup.config.js => rollup.config.mjs} (89%) rename packages/use-enhanced-reducer/{rollup.config.js => rollup.config.mjs} (80%) rename scripts/{ => rollup-plugins}/globals.rollup.config.js (82%) create mode 100644 scripts/rollup-plugins/index.js create mode 100644 scripts/rollup-plugins/package.json rename scripts/{ => rollup-plugins}/rollup-utils.js (100%) diff --git a/.changeset/yellow-seahorses-learn.md b/.changeset/yellow-seahorses-learn.md new file mode 100644 index 000000000000..34ab66cbbf5a --- /dev/null +++ b/.changeset/yellow-seahorses-learn.md @@ -0,0 +1,5 @@ +--- +'@data-client/react': patch +--- + +Fix pnp compatibility by import change diff --git a/.circleci/config.yml b/.circleci/config.yml index 2a6cd9a21052..dc106a48a6ab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,9 +39,9 @@ jobs: npm pkg set 'workspaces[]'='examples/normalizr-relationships' - restore_cache: keys: - - v14-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }} + - v15-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }} # fallback to using the latest cache if no exact match is found - - v14-dependencies- + - v15-dependencies- - run: name: yarn install command: | @@ -50,7 +50,7 @@ jobs: paths: - .yarn/cache - .yarn/install-state.gz - key: v14-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }} + key: v15-dependencies-{{ checksum "yarn.lock" }}-{{ checksum "examples/github-app/package.json" }}-{{ checksum "examples/todo-app/package.json" }} - run: yarn run ci:build:types - run: yarn run ci:build-test-lib - persist_to_workspace: @@ -62,10 +62,11 @@ jobs: - project/examples/todo-app - project/examples/github-app - project/examples/normalizr-relationships - - project/node_modules - project/packages - project/scripts - project/.yarnrc.yml + - project/.pnp.cjs + - project/.pnp.loader.mjs - project/babel.config.js - project/eslint.config.mjs - project/jest.config.js @@ -147,7 +148,7 @@ jobs: - run: # we must use npm because yarn 4 isn't compatible with legacy node versions command: | - ANANSI_JEST_TYPECHECK=false npm test --ci --maxWorkers=2 --selectProjects Node + ANANSI_JEST_TYPECHECK=false yarn test --ci --maxWorkers=2 --selectProjects Node setup-esmodule-types: executor: node @@ -225,7 +226,7 @@ jobs: - run: command: | cd examples/todo-app - npm run build:browser -- --env readable + yarn run build:browser --env readable - run: command: | cd examples/normalizr-relationships diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 7efca3f1130e..73bdf9f95d94 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode" + "esbenp.prettier-vscode", + "arcanis.vscode-zipfs" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index f83dad098228..3df89285ad94 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "eslint.nodePath": "node_modules", + "eslint.nodePath": ".yarn/sdks", "typescript.format.enable": true, "typescript.validate.enable": true, "[javascript]": { @@ -18,7 +18,7 @@ "typescriptreact" ], "eslint.format.enable": true, - "typescript.tsdk": "node_modules/typescript/lib", + "typescript.tsdk": ".yarn/sdks/typescript/lib", "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { "source.fixAll.eslint": "explicit" @@ -52,11 +52,15 @@ "**/versioned_docs": true, "**/*_versioned_docs": true, "**/v8.log": true, - "website/src/components/Playground/editor-types": true + "website/src/components/Playground/editor-types": true, + "**/.yarn": true, + "**/.pnp.*": true }, "files.readonlyExclude": { "**/.next": true, "**/v8.log": true, "website/src/components/Playground/editor-types": true }, + "prettier.prettierPath": ".yarn/sdks/prettier/index.cjs", + "typescript.enablePromptUseWorkspaceTsdk": true } diff --git a/.yarn/sdks/eslint/bin/eslint.js b/.yarn/sdks/eslint/bin/eslint.js new file mode 100755 index 000000000000..e6604ff595ec --- /dev/null +++ b/.yarn/sdks/eslint/bin/eslint.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire, register} = require(`module`); +const {resolve} = require(`path`); +const {pathToFileURL} = require(`url`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); +const absRequire = createRequire(absPnpApiPath); + +const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); +const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require eslint/bin/eslint.js + require(absPnpApiPath).setup(); + if (isPnpLoaderEnabled && register) { + register(pathToFileURL(absPnpLoaderPath)); + } + } +} + +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +// Defer to the real eslint/bin/eslint.js your application uses +module.exports = wrapWithUserWrapper(absRequire(`eslint/bin/eslint.js`)); diff --git a/.yarn/sdks/eslint/package.json b/.yarn/sdks/eslint/package.json new file mode 100644 index 000000000000..eb31c3c4a713 --- /dev/null +++ b/.yarn/sdks/eslint/package.json @@ -0,0 +1,27 @@ +{ + "name": "eslint", + "version": "9.17.0-sdk", + "main": "./lib/api.js", + "type": "commonjs", + "bin": { + "eslint": "./bin/eslint.js" + }, + "exports": { + ".": { + "types": "./lib/types/index.d.ts", + "default": "./lib/api.js" + }, + "./package.json": "./package.json", + "./use-at-your-own-risk": { + "types": "./lib/types/use-at-your-own-risk.d.ts", + "default": "./lib/unsupported-api.js" + }, + "./rules": { + "types": "./lib/types/rules/index.d.ts" + }, + "./universal": { + "types": "./lib/types/universal.d.ts", + "default": "./lib/universal.js" + } + } +} diff --git a/.yarn/sdks/integrations.yml b/.yarn/sdks/integrations.yml new file mode 100644 index 000000000000..aa9d0d0ad81a --- /dev/null +++ b/.yarn/sdks/integrations.yml @@ -0,0 +1,5 @@ +# This file is automatically generated by @yarnpkg/sdks. +# Manual changes might be lost! + +integrations: + - vscode diff --git a/.yarn/sdks/prettier/bin/prettier.cjs b/.yarn/sdks/prettier/bin/prettier.cjs new file mode 100755 index 000000000000..9a4098f7dcd3 --- /dev/null +++ b/.yarn/sdks/prettier/bin/prettier.cjs @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire, register} = require(`module`); +const {resolve} = require(`path`); +const {pathToFileURL} = require(`url`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); +const absRequire = createRequire(absPnpApiPath); + +const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); +const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require prettier/bin/prettier.cjs + require(absPnpApiPath).setup(); + if (isPnpLoaderEnabled && register) { + register(pathToFileURL(absPnpLoaderPath)); + } + } +} + +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +// Defer to the real prettier/bin/prettier.cjs your application uses +module.exports = wrapWithUserWrapper(absRequire(`prettier/bin/prettier.cjs`)); diff --git a/.yarn/sdks/prettier/index.cjs b/.yarn/sdks/prettier/index.cjs new file mode 100644 index 000000000000..57cb2ab17f3c --- /dev/null +++ b/.yarn/sdks/prettier/index.cjs @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire, register} = require(`module`); +const {resolve} = require(`path`); +const {pathToFileURL} = require(`url`); + +const relPnpApiPath = "../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); +const absRequire = createRequire(absPnpApiPath); + +const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); +const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require prettier + require(absPnpApiPath).setup(); + if (isPnpLoaderEnabled && register) { + register(pathToFileURL(absPnpLoaderPath)); + } + } +} + +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +// Defer to the real prettier your application uses +module.exports = wrapWithUserWrapper(absRequire(`prettier`)); diff --git a/.yarn/sdks/prettier/package.json b/.yarn/sdks/prettier/package.json new file mode 100644 index 000000000000..b9ab57f09d64 --- /dev/null +++ b/.yarn/sdks/prettier/package.json @@ -0,0 +1,7 @@ +{ + "name": "prettier", + "version": "3.4.2-sdk", + "main": "./index.cjs", + "type": "commonjs", + "bin": "./bin/prettier.cjs" +} diff --git a/.yarn/sdks/typescript/bin/tsc b/.yarn/sdks/typescript/bin/tsc new file mode 100755 index 000000000000..867a7bdfe259 --- /dev/null +++ b/.yarn/sdks/typescript/bin/tsc @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire, register} = require(`module`); +const {resolve} = require(`path`); +const {pathToFileURL} = require(`url`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); +const absRequire = createRequire(absPnpApiPath); + +const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); +const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/bin/tsc + require(absPnpApiPath).setup(); + if (isPnpLoaderEnabled && register) { + register(pathToFileURL(absPnpLoaderPath)); + } + } +} + +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +// Defer to the real typescript/bin/tsc your application uses +module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsc`)); diff --git a/.yarn/sdks/typescript/bin/tsserver b/.yarn/sdks/typescript/bin/tsserver new file mode 100755 index 000000000000..3fc5aa31cc91 --- /dev/null +++ b/.yarn/sdks/typescript/bin/tsserver @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +const {existsSync} = require(`fs`); +const {createRequire, register} = require(`module`); +const {resolve} = require(`path`); +const {pathToFileURL} = require(`url`); + +const relPnpApiPath = "../../../../.pnp.cjs"; + +const absPnpApiPath = resolve(__dirname, relPnpApiPath); +const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); +const absRequire = createRequire(absPnpApiPath); + +const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); +const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); + +if (existsSync(absPnpApiPath)) { + if (!process.versions.pnp) { + // Setup the environment to be able to require typescript/bin/tsserver + require(absPnpApiPath).setup(); + if (isPnpLoaderEnabled && register) { + register(pathToFileURL(absPnpLoaderPath)); + } + } +} + +const wrapWithUserWrapper = existsSync(absUserWrapperPath) + ? exports => absRequire(absUserWrapperPath)(exports) + : exports => exports; + +// Defer to the real typescript/bin/tsserver your application uses +module.exports = wrapWithUserWrapper(absRequire(`typescript/bin/tsserver`)); diff --git a/.yarn/sdks/typescript/package.json b/.yarn/sdks/typescript/package.json new file mode 100644 index 000000000000..4c87e4cafbf0 --- /dev/null +++ b/.yarn/sdks/typescript/package.json @@ -0,0 +1,10 @@ +{ + "name": "typescript", + "version": "5.7.2-sdk", + "main": "./lib/typescript.js", + "type": "commonjs", + "bin": { + "tsc": "./bin/tsc", + "tsserver": "./bin/tsserver" + } +} diff --git a/.yarnrc.yml b/.yarnrc.yml index 823d95707f67..5922d5c240be 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -2,7 +2,8 @@ changesetIgnorePatterns: - "**/__tests__/**" - "**/*.md" -nodeLinker: node-modules +nodeLinker: pnp +pnpEnableEsmLoader: true yarnPath: .yarn/releases/yarn-4.5.3.cjs diff --git a/examples/github-app/package-lock.json b/examples/github-app/package-lock.json index 9378065225b7..bb72ff174993 100644 --- a/examples/github-app/package-lock.json +++ b/examples/github-app/package-lock.json @@ -12,10 +12,12 @@ "@anansi/router": "0.10.10", "@ant-design/icons": "^5.0.0", "@data-client/graphql": "^0.14.0", + "@data-client/img": "^0.14.15", "@data-client/react": "^0.14.0", "@data-client/rest": "^0.14.0", "@js-temporal/polyfill": "^0.4.4", "antd": "5.22.5", + "history": "^5.3.0", "parse-link-header": "^2.0.0", "react": "19.0.0", "react-dom": "19.0.0", @@ -3447,6 +3449,28 @@ "url": "https://github.com/sponsors/ntucker" } }, + "node_modules/@data-client/img": { + "version": "0.14.15", + "resolved": "https://registry.npmjs.org/@data-client/img/-/img-0.14.15.tgz", + "integrity": "sha512-d8F+Ld416+nks4hRqs+SDhJtpx0UStz+QH8Tnh2BowsfRrU9o5eBDrXn45ZC3Atj2s1cENtXs4EyrdWzbxoVGA==", + "dependencies": { + "@babel/runtime": "^7.17.0", + "@data-client/endpoint": "^0.14.12" + }, + "funding": { + "url": "https://github.com/sponsors/ntucker" + }, + "peerDependencies": { + "@data-client/react": "^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0", + "@types/react": "^16.14.0 || ^17.0.0 || ^18.0.0-0 || ^19.0.0", + "react": "^16.14.0 || ^17.0.0 || ^18.0.0-0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@data-client/normalizr": { "version": "0.14.16", "resolved": "https://registry.npmjs.org/@data-client/normalizr/-/normalizr-0.14.16.tgz", diff --git a/examples/github-app/package.json b/examples/github-app/package.json index 8217c2efeaf2..2cf7ff941fae 100644 --- a/examples/github-app/package.json +++ b/examples/github-app/package.json @@ -51,10 +51,12 @@ "@anansi/router": "0.10.10", "@ant-design/icons": "^5.0.0", "@data-client/graphql": "^0.14.0", + "@data-client/img": "^0.14.15", "@data-client/react": "^0.14.0", "@data-client/rest": "^0.14.0", "@js-temporal/polyfill": "^0.4.4", "antd": "5.22.5", + "history": "^5.3.0", "parse-link-header": "^2.0.0", "react": "19.0.0", "react-dom": "19.0.0", diff --git a/package.json b/package.json index 46c080aa25a3..ca125c9a3f77 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "examples/benchmark", "examples/normalizr-*", "examples/coin-app", - "website" + "website", + "scripts/rollup-plugins" ], "scripts": { "changeset:version": "run changeset version && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install", diff --git a/packages/core/package.json b/packages/core/package.json index b7b9b2184b83..4561fd9ffbf2 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -126,6 +126,7 @@ }, "devDependencies": { "@anansi/browserslist-config": "^1.4.2", - "@types/node": "^22.0.0" + "@types/node": "^22.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.mjs similarity index 81% rename from packages/core/rollup.config.js rename to packages/core/rollup.config.mjs index 72daa9e4fc6b..6082e437c9ea 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.mjs @@ -1,13 +1,7 @@ -import babel from 'rollup-plugin-babel'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, commonjs, filesize, json, resolve, replace, terser, typeConfig, typeConfigNext } from 'rollup-plugins'; + +import pkg from './package.json' with { type: 'json' }; -import pkg from './package.json'; -import { typeConfig, typeConfigNext } from '../../scripts/rollup-utils'; const dependencies = Object.keys(pkg.dependencies) //.concat(Object.keys(pkg.peerDependencies)) diff --git a/packages/endpoint/package.json b/packages/endpoint/package.json index f4e9631065a5..93cf9b97b968 100644 --- a/packages/endpoint/package.json +++ b/packages/endpoint/package.json @@ -136,6 +136,7 @@ "devDependencies": { "@anansi/browserslist-config": "^1.4.2", "@js-temporal/polyfill": "^0.4.4", - "@types/node": "^22.0.0" + "@types/node": "^22.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/endpoint/rollup.config.js b/packages/endpoint/rollup.config.mjs similarity index 81% rename from packages/endpoint/rollup.config.js rename to packages/endpoint/rollup.config.mjs index 61c1f25f7e54..0e8fda3bb94f 100644 --- a/packages/endpoint/rollup.config.js +++ b/packages/endpoint/rollup.config.mjs @@ -1,13 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import commonjs from 'rollup-plugin-commonjs'; -import dts from 'rollup-plugin-dts'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, dts, commonjs, filesize, json, resolve, replace, terser } from 'rollup-plugins'; -import pkg from './package.json'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies).filter( dep => !['@babel/runtime'].includes(dep), diff --git a/packages/graphql/package.json b/packages/graphql/package.json index ec4d4f9c6196..e83805ec08c3 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -109,6 +109,7 @@ }, "devDependencies": { "@anansi/browserslist-config": "^1.4.2", - "@types/node": "^22.0.0" + "@types/node": "^22.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/graphql/rollup.config.js b/packages/graphql/rollup.config.mjs similarity index 79% rename from packages/graphql/rollup.config.js rename to packages/graphql/rollup.config.mjs index c9f7a4562e5c..6d5873105254 100644 --- a/packages/graphql/rollup.config.js +++ b/packages/graphql/rollup.config.mjs @@ -1,13 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, commonjs, filesize, json, resolve, replace, terser, typeConfig, typeConfigNext } from 'rollup-plugins'; -import pkg from './package.json'; -import { typeConfig } from '../../scripts/rollup-utils'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies).filter( dep => !['@babel/runtime'].includes(dep), diff --git a/packages/img/package.json b/packages/img/package.json index 8abf9ac78446..fc3804378230 100644 --- a/packages/img/package.json +++ b/packages/img/package.json @@ -87,6 +87,7 @@ "@data-client/react": "workspace:*", "@types/node": "^22.0.0", "@types/react": "19.0.2", - "react": "19.0.0" + "react": "19.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/img/rollup.config.js b/packages/img/rollup.config.mjs similarity index 83% rename from packages/img/rollup.config.js rename to packages/img/rollup.config.mjs index bcccc262f572..677c79ba0471 100644 --- a/packages/img/rollup.config.js +++ b/packages/img/rollup.config.mjs @@ -1,12 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, commonjs, filesize, json, resolve, replace, terser } from 'rollup-plugins'; -import pkg from './package.json'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies) .concat(Object.keys(pkg.peerDependencies)) diff --git a/packages/normalizr/package.json b/packages/normalizr/package.json index 3550e7ae68d0..5c6a9b77a3a2 100644 --- a/packages/normalizr/package.json +++ b/packages/normalizr/package.json @@ -121,6 +121,7 @@ "devDependencies": { "@anansi/browserslist-config": "^1.4.2", "@types/node": "^22.0.0", - "immutable": "4.2.2" + "immutable": "4.2.2", + "rollup-plugins": "workspace:*" } } diff --git a/packages/normalizr/rollup.config.js b/packages/normalizr/rollup.config.mjs similarity index 89% rename from packages/normalizr/rollup.config.js rename to packages/normalizr/rollup.config.mjs index 084605ed820e..662d77da92e9 100644 --- a/packages/normalizr/rollup.config.js +++ b/packages/normalizr/rollup.config.mjs @@ -1,9 +1,4 @@ -import babel from 'rollup-plugin-babel'; -import commonjs from 'rollup-plugin-commonjs'; -import dts from 'rollup-plugin-dts'; -import filesize from 'rollup-plugin-filesize'; -import resolve from 'rollup-plugin-node-resolve'; -import { terser } from 'rollup-plugin-terser'; +import { babel, commonjs, filesize, dts, resolve, terser } from 'rollup-plugins'; const name = 'normalizr'; diff --git a/packages/react/package.json b/packages/react/package.json index eb4941232bd6..1483ad94d1cd 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -157,7 +157,7 @@ "build:js:node": "BROWSERSLIST_ENV=node12 yarn g:rollup", "build:js:browser": "BROWSERSLIST_ENV=legacy yarn g:rollup", "build:bundle": "yarn g:runs build:js:\\* && echo '{\"type\":\"commonjs\"}' > dist/package.json", - "build:clean": "yarn g:clean ./index.d.ts", + "build:clean": "yarn g:clean index.d.ts next.d.ts native", "build:legacy-types": "yarn g:downtypes lib ts3.4", "build": "run build:lib && run build:legacy:lib && run build:native:lib && run build:bundle", "dev": "run build:lib -w", @@ -193,6 +193,7 @@ "@types/react": "19.0.2", "qs": "^6.13.1", "react": "19.0.0", - "react-native": "^0.76.0" + "react-native": "^0.76.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/react/rollup.config.js b/packages/react/rollup.config.mjs similarity index 86% rename from packages/react/rollup.config.js rename to packages/react/rollup.config.mjs index 832232baebfa..92c2d4a625bf 100644 --- a/packages/react/rollup.config.js +++ b/packages/react/rollup.config.mjs @@ -1,14 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import banner from 'rollup-plugin-banner2'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, banner, commonjs, filesize, json, resolve, replace, terser, typeConfig, typeConfigNext } from 'rollup-plugins'; -import pkg from './package.json'; -import { typeConfig, typeConfigNext } from '../../scripts/rollup-utils'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies) .concat(Object.keys(pkg.peerDependencies)) diff --git a/packages/react/src/hooks/useCancelling.ts b/packages/react/src/hooks/useCancelling.ts index 91e141aa25a9..6b6d0b388f4c 100644 --- a/packages/react/src/hooks/useCancelling.ts +++ b/packages/react/src/hooks/useCancelling.ts @@ -1,4 +1,4 @@ -import type { EndpointInterface } from '@data-client/normalizr'; +import type { EndpointInterface } from '@data-client/core'; import { useMemo, useRef } from 'react'; /** diff --git a/packages/rest/package.json b/packages/rest/package.json index 7ae2d7dce62c..900b1fa71915 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -136,6 +136,7 @@ }, "devDependencies": { "@anansi/browserslist-config": "^1.4.2", - "@types/node": "^22.0.0" + "@types/node": "^22.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/rest/rollup.config.js b/packages/rest/rollup.config.mjs similarity index 80% rename from packages/rest/rollup.config.js rename to packages/rest/rollup.config.mjs index 346219a967ae..3ef8ac06e052 100644 --- a/packages/rest/rollup.config.js +++ b/packages/rest/rollup.config.mjs @@ -1,13 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, commonjs, filesize, json, resolve, replace, terser, typeConfig, typeConfigNext } from 'rollup-plugins'; -import pkg from './package.json'; -import { typeConfig, typeConfigNext } from '../../scripts/rollup-utils'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies).filter( dep => !['@babel/runtime'].includes(dep), diff --git a/packages/ssr/package.json b/packages/ssr/package.json index fa45f5aa51a0..4ea8fd754632 100644 --- a/packages/ssr/package.json +++ b/packages/ssr/package.json @@ -141,6 +141,7 @@ "next": "^15.0.0", "react": "19.0.0", "react-dom": "19.0.0", - "redux": "^5.0.0" + "redux": "^5.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/ssr/rollup.config.js b/packages/ssr/rollup.config.mjs similarity index 84% rename from packages/ssr/rollup.config.js rename to packages/ssr/rollup.config.mjs index a0e4b63ec982..92719b449848 100644 --- a/packages/ssr/rollup.config.js +++ b/packages/ssr/rollup.config.mjs @@ -1,13 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import banner from 'rollup-plugin-banner2'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, banner, commonjs, filesize, json, resolve, replace, terser } from 'rollup-plugins'; -import pkg from './package.json'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies) .concat(Object.keys(pkg.peerDependencies)) diff --git a/packages/test/package.json b/packages/test/package.json index 0b82f10ef66f..8fb5a6d0aec5 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -160,6 +160,7 @@ "@types/react-test-renderer": "19.0.0", "jest": "^29.5.0", "react": "19.0.0", - "react-dom": "19.0.0" + "react-dom": "19.0.0", + "rollup-plugins": "workspace:*" } } diff --git a/packages/test/rollup.config.js b/packages/test/rollup.config.mjs similarity index 89% rename from packages/test/rollup.config.js rename to packages/test/rollup.config.mjs index 70223a74a4af..0e0334126485 100644 --- a/packages/test/rollup.config.js +++ b/packages/test/rollup.config.mjs @@ -1,9 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import banner from 'rollup-plugin-banner2'; -import commonjs from 'rollup-plugin-commonjs'; -import resolve from 'rollup-plugin-node-resolve'; +import {babel, banner, commonjs, resolve} from 'rollup-plugins'; -import pkg from './package.json'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.dependencies) .concat(Object.keys(pkg.peerDependencies)) diff --git a/packages/use-enhanced-reducer/package.json b/packages/use-enhanced-reducer/package.json index df6bedb6e680..d0580c954e25 100644 --- a/packages/use-enhanced-reducer/package.json +++ b/packages/use-enhanced-reducer/package.json @@ -88,6 +88,7 @@ "devDependencies": { "@anansi/browserslist-config": "^1.4.2", "@types/node": "^22.0.0", - "@types/react": "19.0.2" + "@types/react": "19.0.2", + "rollup-plugins": "workspace:*" } } diff --git a/packages/use-enhanced-reducer/rollup.config.js b/packages/use-enhanced-reducer/rollup.config.mjs similarity index 80% rename from packages/use-enhanced-reducer/rollup.config.js rename to packages/use-enhanced-reducer/rollup.config.mjs index a5886692cccf..21290ac11f7b 100644 --- a/packages/use-enhanced-reducer/rollup.config.js +++ b/packages/use-enhanced-reducer/rollup.config.mjs @@ -1,13 +1,6 @@ -import babel from 'rollup-plugin-babel'; -import banner from 'rollup-plugin-banner2'; -import commonjs from 'rollup-plugin-commonjs'; -import filesize from 'rollup-plugin-filesize'; -import json from 'rollup-plugin-json'; -import resolve from 'rollup-plugin-node-resolve'; -import replace from 'rollup-plugin-replace'; -import { terser } from 'rollup-plugin-terser'; +import { babel, banner, commonjs, filesize, json, resolve, replace, terser } from 'rollup-plugins'; -import pkg from './package.json'; +import pkg from './package.json' with { type: 'json' }; const dependencies = Object.keys(pkg.peerDependencies).filter( dep => !['@babel/runtime'].includes(dep), diff --git a/scripts/copywebsitetypes.sh b/scripts/copywebsitetypes.sh index d574ab8b602e..0194a1646ba4 100755 --- a/scripts/copywebsitetypes.sh +++ b/scripts/copywebsitetypes.sh @@ -15,4 +15,4 @@ cp ./packages/react/ssr.d.ts ./website/src/components/Playground/editor-types/@d cp ./packages/react/redux.d.ts ./website/src/components/Playground/editor-types/@data-client/react/redux.d.ts cp ./node_modules/@types/react/index.d.ts ./website/src/components/Playground/editor-types/react.d.ts rm ./website/src/components/Playground/editor-types/globals.d.ts -yarn run rollup --config ./scripts/globals.rollup.config.js \ No newline at end of file +yarn run rollup --config ./scripts/rollup-plugins/globals.rollup.config.js \ No newline at end of file diff --git a/scripts/globals.rollup.config.js b/scripts/rollup-plugins/globals.rollup.config.js similarity index 82% rename from scripts/globals.rollup.config.js rename to scripts/rollup-plugins/globals.rollup.config.js index 9b346d6da305..c0c6d8da0384 100644 --- a/scripts/globals.rollup.config.js +++ b/scripts/rollup-plugins/globals.rollup.config.js @@ -1,4 +1,4 @@ -import { typeConfig } from './rollup-utils'; +import { typeConfig } from './rollup-utils.js'; export default [ { diff --git a/scripts/rollup-plugins/index.js b/scripts/rollup-plugins/index.js new file mode 100644 index 000000000000..1e0ec3cbefdb --- /dev/null +++ b/scripts/rollup-plugins/index.js @@ -0,0 +1,10 @@ +export {default as babel} from 'rollup-plugin-babel'; +export {default as banner} from 'rollup-plugin-banner2'; +export {default as commonjs} from 'rollup-plugin-commonjs'; +export {default as resolve} from 'rollup-plugin-node-resolve'; +export {default as filesize} from 'rollup-plugin-filesize'; +export {default as json} from 'rollup-plugin-json'; +export {default as replace} from 'rollup-plugin-replace'; +export { terser } from 'rollup-plugin-terser'; +export {default as dts} from 'rollup-plugin-dts'; +export * from './rollup-utils.js' \ No newline at end of file diff --git a/scripts/rollup-plugins/package.json b/scripts/rollup-plugins/package.json new file mode 100644 index 000000000000..1219d7b82255 --- /dev/null +++ b/scripts/rollup-plugins/package.json @@ -0,0 +1,26 @@ +{ + "name": "rollup-plugins", + "version": "1.0.0", + "main": "index.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "rollup-plugin-babel": "^4.4.0", + "rollup-plugin-banner2": "^1.2.2", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-dts": "^5.0.0", + "rollup-plugin-filesize": "^9.1.2", + "rollup-plugin-json": "^4.0.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-replace": "^2.2.0", + "rollup-plugin-terser": "^7.0.2" + }, + "devDependencies": { + "rollup-plugins": "workspace:*" + } +} diff --git a/scripts/rollup-utils.js b/scripts/rollup-plugins/rollup-utils.js similarity index 100% rename from scripts/rollup-utils.js rename to scripts/rollup-plugins/rollup-utils.js diff --git a/yarn.lock b/yarn.lock index 75b2f0b46b9b..e6eb3502fd61 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3114,6 +3114,7 @@ __metadata: "@data-client/normalizr": "npm:^0.14.16" "@types/node": "npm:^22.0.0" flux-standard-action: "npm:^2.1.1" + rollup-plugins: "workspace:*" languageName: unknown linkType: soft @@ -3125,6 +3126,7 @@ __metadata: "@babel/runtime": "npm:^7.17.0" "@js-temporal/polyfill": "npm:^0.4.4" "@types/node": "npm:^22.0.0" + rollup-plugins: "workspace:*" languageName: unknown linkType: soft @@ -3136,6 +3138,7 @@ __metadata: "@babel/runtime": "npm:^7.17.0" "@data-client/endpoint": "npm:^0.14.17" "@types/node": "npm:^22.0.0" + rollup-plugins: "workspace:*" languageName: unknown linkType: soft @@ -3150,6 +3153,7 @@ __metadata: "@types/node": "npm:^22.0.0" "@types/react": "npm:19.0.2" react: "npm:19.0.0" + rollup-plugins: "workspace:*" peerDependencies: "@data-client/react": ^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0 "@types/react": ^16.14.0 || ^17.0.0 || ^18.0.0-0 || ^19.0.0 @@ -3177,6 +3181,7 @@ __metadata: "@babel/runtime": "npm:^7.17.0" "@types/node": "npm:^22.0.0" immutable: "npm:4.2.2" + rollup-plugins: "workspace:*" languageName: unknown linkType: soft @@ -3195,6 +3200,7 @@ __metadata: qs: "npm:^6.13.1" react: "npm:19.0.0" react-native: "npm:^0.76.0" + rollup-plugins: "workspace:*" peerDependencies: "@react-navigation/native": ^6.0.0 || ^7.0.0 "@types/react": ^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-0 || ^19.0.0 @@ -3234,6 +3240,7 @@ __metadata: "@data-client/endpoint": "npm:^0.14.17" "@types/node": "npm:^22.0.0" path-to-regexp: "npm:^6.3.0" + rollup-plugins: "workspace:*" languageName: unknown linkType: soft @@ -3252,6 +3259,7 @@ __metadata: react: "npm:19.0.0" react-dom: "npm:19.0.0" redux: "npm:^5.0.0" + rollup-plugins: "workspace:*" peerDependencies: "@data-client/react": ^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0 "@data-client/redux": ^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0 @@ -3285,6 +3293,7 @@ __metadata: jest: "npm:^29.5.0" react: "npm:19.0.0" react-dom: "npm:19.0.0" + rollup-plugins: "workspace:*" peerDependencies: "@data-client/react": ^0.12.15 || ^0.13.0 || ^0.14.0 "@testing-library/react-hooks": ^8.0.0 @@ -3320,6 +3329,7 @@ __metadata: "@anansi/browserslist-config": "npm:^1.4.2" "@types/node": "npm:^22.0.0" "@types/react": "npm:19.0.2" + rollup-plugins: "workspace:*" peerDependencies: "@types/react": ^16.14.0 || ^17.0.0 || ^18.0.0-0 || ^18.0.0 || ^19.0.0-0 || ^19.0.0 react: ^16.14.0 || ^17.0.0 || ^18.0.0-0 || ^18.0.0 || ^19.0.0-0 || ^19.0.0 @@ -26967,6 +26977,23 @@ __metadata: languageName: node linkType: hard +"rollup-plugins@workspace:*, rollup-plugins@workspace:scripts/rollup-plugins": + version: 0.0.0-use.local + resolution: "rollup-plugins@workspace:scripts/rollup-plugins" + dependencies: + rollup-plugin-babel: "npm:^4.4.0" + rollup-plugin-banner2: "npm:^1.2.2" + rollup-plugin-commonjs: "npm:^10.1.0" + rollup-plugin-dts: "npm:^5.0.0" + rollup-plugin-filesize: "npm:^9.1.2" + rollup-plugin-json: "npm:^4.0.0" + rollup-plugin-node-resolve: "npm:^5.2.0" + rollup-plugin-replace: "npm:^2.2.0" + rollup-plugin-terser: "npm:^7.0.2" + rollup-plugins: "workspace:*" + languageName: unknown + linkType: soft + "rollup-pluginutils@npm:^2.5.0, rollup-pluginutils@npm:^2.6.0, rollup-pluginutils@npm:^2.8.1": version: 2.8.2 resolution: "rollup-pluginutils@npm:2.8.2"