From 7a07c73bae728bd475625b8eaf10d159631e754b Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sat, 11 Nov 2023 22:38:33 +0000 Subject: [PATCH 1/2] chore: dogfood rollup configs --- package-lock.json | 11 ++++- packages/base-rollup-config/index.mjs | 7 ++- .../internal-playwright-helpers/package.json | 3 ++ .../rollup.config.mjs | 49 ++++--------------- .../internal-playwright-testids/package.json | 3 ++ .../rollup.config.mjs | 48 ++++-------------- packages/internal-test-env/package.json | 3 ++ packages/internal-test-env/rollup.config.mjs | 47 ++---------------- 8 files changed, 45 insertions(+), 126 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6dc6912a..dc4ebbd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13804,6 +13804,9 @@ "@inrupt/internal-playwright-testids": "2.4.1", "@inrupt/internal-test-env": "2.4.1" }, + "devDependencies": { + "@inrupt/base-rollup-config": "^2.4.1" + }, "peerDependencies": { "@playwright/test": "^1.37.0" } @@ -13811,7 +13814,10 @@ "packages/internal-playwright-testids": { "name": "@inrupt/internal-playwright-testids", "version": "2.4.1", - "license": "MIT" + "license": "MIT", + "devDependencies": { + "@inrupt/base-rollup-config": "^2.4.1" + } }, "packages/internal-test-env": { "name": "@inrupt/internal-test-env", @@ -13824,6 +13830,9 @@ "@jeswr/css-auth-utils": "^1.4.0", "deepmerge-json": "^1.5.0", "dotenv": "^16.3.1" + }, + "devDependencies": { + "@inrupt/base-rollup-config": "^2.4.1" } }, "packages/jest-jsdom-polyfills": { diff --git a/packages/base-rollup-config/index.mjs b/packages/base-rollup-config/index.mjs index 801b6fff..8fb665b8 100644 --- a/packages/base-rollup-config/index.mjs +++ b/packages/base-rollup-config/index.mjs @@ -22,7 +22,7 @@ import typescript from "rollup-plugin-typescript2"; import { createRequire } from "node:module"; const require = createRequire(import.meta.url); -export const createSharedConfig = pkg => ({ +export const createSharedConfig = (pkg) => ({ plugins: [ typescript({ // Use our own version of TypeScript, rather than the one bundled with the plugin: @@ -34,7 +34,10 @@ export const createSharedConfig = pkg => ({ }, }), ], - external: Object.keys(pkg.dependencies), + external: [ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + ], // The following option is useful because symlinks are used in monorepos preserveSymlinks: true, }); diff --git a/packages/internal-playwright-helpers/package.json b/packages/internal-playwright-helpers/package.json index f145c7f5..a728c1b4 100644 --- a/packages/internal-playwright-helpers/package.json +++ b/packages/internal-playwright-helpers/package.json @@ -25,5 +25,8 @@ }, "peerDependencies": { "@playwright/test": "^1.37.0" + }, + "devDependencies": { + "@inrupt/base-rollup-config": "^2.4.1" } } diff --git a/packages/internal-playwright-helpers/rollup.config.mjs b/packages/internal-playwright-helpers/rollup.config.mjs index 3d243ccc..0ab64f4c 100644 --- a/packages/internal-playwright-helpers/rollup.config.mjs +++ b/packages/internal-playwright-helpers/rollup.config.mjs @@ -1,36 +1,9 @@ -// The following is only possible from Node 18 onwards -// import pkg from "./package.json" assert { type: "json" }; - -// Until we only support Node 18+, this should be used instead -// (see https://rollupjs.org/guide/en/#importing-packagejson) -import { createRequire } from "node:module"; -const require = createRequire(import.meta.url); -const pkg = require("./package.json"); - -import typescript from "rollup-plugin-typescript2"; - -const external = [ - ...Object.keys(pkg.dependencies || {}), - ...Object.keys(pkg.peerDependencies || {}), -]; - -const plugins = [ - typescript({ - // Use our own version of TypeScript, rather than the one bundled with the plugin: - typescript: require("typescript"), - tsconfigOverride: { - compilerOptions: { - module: "esnext", - }, - }, - }), -]; - -const rollupDefaultConfig = { external, plugins }; +import { createSharedConfig } from "@inrupt/base-rollup-config"; +import pkg from "./package.json" assert { type: "json" }; export default [ { - ...rollupDefaultConfig, + ...createSharedConfig(pkg), input: "src/index.ts", output: [ { @@ -42,16 +15,12 @@ export default [ entryFileNames: "[name].es.js", format: "esm", }, + { + dir: "dist", + entryFileNames: "[name].mjs", + format: "esm", + preserveModules: true, + } ], }, - { - ...rollupDefaultConfig, - input: ["src/index.ts"], - output: { - dir: "dist", - entryFileNames: "[name].mjs", - format: "esm", - preserveModules: true, - }, - }, ]; diff --git a/packages/internal-playwright-testids/package.json b/packages/internal-playwright-testids/package.json index d3588d75..f0c140f9 100644 --- a/packages/internal-playwright-testids/package.json +++ b/packages/internal-playwright-testids/package.json @@ -18,5 +18,8 @@ "require": "./dist/index.js", "import": "./dist/index.mjs" } + }, + "devDependencies": { + "@inrupt/base-rollup-config": "^2.4.1" } } diff --git a/packages/internal-playwright-testids/rollup.config.mjs b/packages/internal-playwright-testids/rollup.config.mjs index 87a39a66..50fde05d 100644 --- a/packages/internal-playwright-testids/rollup.config.mjs +++ b/packages/internal-playwright-testids/rollup.config.mjs @@ -1,35 +1,9 @@ -// The following is only possible from Node 18 onwards -// import pkg from "./package.json" assert { type: "json" }; - -// Until we only support Node 18+, this should be used instead -// (see https://rollupjs.org/guide/en/#importing-packagejson) -import { createRequire } from "node:module"; -const require = createRequire(import.meta.url); -const pkg = require("./package.json"); - -import typescript from "rollup-plugin-typescript2"; - -const external = [ - ...Object.keys(pkg.dependencies || {}), -]; - -const plugins = [ - typescript({ - // Use our own version of TypeScript, rather than the one bundled with the plugin: - typescript: require("typescript"), - tsconfigOverride: { - compilerOptions: { - module: "esnext", - }, - }, - }), -]; - -const rollupDefaultConfig = { external, plugins }; +import { createSharedConfig } from "@inrupt/base-rollup-config"; +import pkg from "./package.json" assert { type: "json" }; export default [ { - ...rollupDefaultConfig, + ...createSharedConfig(pkg), input: "src/index.ts", output: [ { @@ -41,16 +15,12 @@ export default [ entryFileNames: "[name].es.js", format: "esm", }, + { + dir: "dist", + entryFileNames: "[name].mjs", + format: "esm", + preserveModules: true, + }, ], }, - { - ...rollupDefaultConfig, - input: ["src/index.ts"], - output: { - dir: "dist", - entryFileNames: "[name].mjs", - format: "esm", - preserveModules: true, - }, - }, ]; diff --git a/packages/internal-test-env/package.json b/packages/internal-test-env/package.json index 655ae75e..98394d6c 100644 --- a/packages/internal-test-env/package.json +++ b/packages/internal-test-env/package.json @@ -26,5 +26,8 @@ "@jeswr/css-auth-utils": "^1.4.0", "deepmerge-json": "^1.5.0", "dotenv": "^16.3.1" + }, + "devDependencies": { + "@inrupt/base-rollup-config": "^2.4.1" } } diff --git a/packages/internal-test-env/rollup.config.mjs b/packages/internal-test-env/rollup.config.mjs index 144e1874..2f458bc1 100644 --- a/packages/internal-test-env/rollup.config.mjs +++ b/packages/internal-test-env/rollup.config.mjs @@ -1,37 +1,9 @@ -// The following is only possible from Node 18 onwards -// import pkg from "./package.json" assert { type: "json" }; - -// Until we only support Node 18+, this should be used instead -// (see https://rollupjs.org/guide/en/#importing-packagejson) -import { createRequire } from "node:module"; -const require = createRequire(import.meta.url); -const pkg = require("./package.json"); - -import typescript from "rollup-plugin-typescript2"; - -const external = [ - ...Object.keys(pkg.dependencies || {}), - "@inrupt/solid-client-authn-node", - "@inrupt/solid-client", -]; - -const plugins = [ - typescript({ - // Use our own version of TypeScript, rather than the one bundled with the plugin: - typescript: require("typescript"), - tsconfigOverride: { - compilerOptions: { - module: "esnext", - }, - }, - }), -]; - -const rollupDefaultConfig = { external, plugins }; +import { createSharedConfig } from "@inrupt/base-rollup-config"; +import pkg from "./package.json" assert { type: "json" }; export default [ { - ...rollupDefaultConfig, + ...createSharedConfig(pkg), external: [ "dotenv", "path", @@ -50,19 +22,6 @@ export default [ entryFileNames: "[name].es.js", format: "esm", }, - ], - }, - { - ...rollupDefaultConfig, - external: [ - "dotenv", - "path", - "deepmerge-json", - "@inrupt/solid-client-authn-node", - "@inrupt/solid-client", - ], - input: ["index.ts"], - output: [ { dir: "dist", entryFileNames: "[name].d.ts", From e9ae1b0952418d6d63e9c36773bddf5ef646bca7 Mon Sep 17 00:00:00 2001 From: Jesse Wright <63333554+jeswr@users.noreply.github.com> Date: Sat, 11 Nov 2023 22:40:04 +0000 Subject: [PATCH 2/2] chore: remove unecessary externals --- packages/internal-test-env/rollup.config.mjs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/internal-test-env/rollup.config.mjs b/packages/internal-test-env/rollup.config.mjs index 2f458bc1..1157fe58 100644 --- a/packages/internal-test-env/rollup.config.mjs +++ b/packages/internal-test-env/rollup.config.mjs @@ -4,13 +4,6 @@ import pkg from "./package.json" assert { type: "json" }; export default [ { ...createSharedConfig(pkg), - external: [ - "dotenv", - "path", - "deepmerge-json", - "@inrupt/solid-client-authn-node", - "@inrupt/solid-client", - ], input: "index.ts", output: [ {