diff --git a/.github/workflows/pkg-pr.yml b/.github/workflows/pkg-pr.yml index 9a61f627..4f32a7e1 100644 --- a/.github/workflows/pkg-pr.yml +++ b/.github/workflows/pkg-pr.yml @@ -14,6 +14,7 @@ jobs: cache: "pnpm" - name: Install dependencies run: pnpm install - + - name: Build + run: pnpm build - name: Publish preview package run: pnpx pkg-pr-new publish --no-template diff --git a/package.json b/package.json index 5e41734a..20869014 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "version": "8.26.1", "description": "Monitor if a component is inside the viewport, using IntersectionObserver API", "type": "commonjs", - "source": "./src/index.tsx", - "main": "./dist/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/index.d.ts", + "source": "src/index.tsx", + "main": "dist/index.js", + "module": "dist/esm/index.js", + "types": "dist/index.d.ts", "exports": { "./test-utils": { "types": "./dist/test-utils.d.mts", @@ -19,6 +19,7 @@ "default": "./dist/index.mjs" } }, + "files": ["dist"], "author": "Daniel Schmidt", "license": "MIT", "sideEffects": false, @@ -26,9 +27,6 @@ "type": "git", "url": "https://github.com/thebuilder/react-intersection-observer.git" }, - "engines": { - "pnpm": ">=9" - }, "packageManager": "pnpm@9.5.0+sha256.dbdf5961c32909fb030595a9daa1dae720162e658609a8f92f2fa99835510ca5", "scripts": { "prebuild": "rm -rf dist lib", @@ -36,13 +34,11 @@ "build:bundle": "tsup src/index.tsx", "build:legacy": "tsup src/index.tsx --format esm --legacy-output --no-clean --no-dts", "build:utils": "tsup src/test-utils.ts --no-clean --no-sourcemap", - "build:copy": "node scripts/build-copy.cjs", "postbuild": "size-limit", "dev": "run-p dev:*", "dev:package": "tsup src/index.tsx --watch", "dev:storybook": "pnpm --filter storybook dev", "lint": "biome check .", - "release": "np --contents dist", "version": "pnpm build", "storybook:build": "pnpm build:bundle && pnpm --filter storybook build", "test": "vitest" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94f398f9..8eb5197c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -479,6 +479,7 @@ packages: '@babel/plugin-proposal-class-properties@7.12.1': resolution: {integrity: sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w==} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead. peerDependencies: '@babel/core': ^7.0.0-0 @@ -491,6 +492,7 @@ packages: '@babel/plugin-proposal-unicode-property-regex@7.18.6': resolution: {integrity: sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==} engines: {node: '>=4'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-unicode-property-regex instead. peerDependencies: '@babel/core': ^7.0.0-0 @@ -3339,10 +3341,6 @@ packages: engines: {node: '>=12'} hasBin: true - escalade@3.1.1: - resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} - engines: {node: '>=6'} - escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} @@ -3636,6 +3634,7 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} @@ -3824,6 +3823,7 @@ packages: inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -9308,7 +9308,7 @@ snapshots: babel-plugin-polyfill-corejs2@0.4.11(@babel/core@7.24.7): dependencies: - '@babel/compat-data': 7.24.7 + '@babel/compat-data': 7.24.4 '@babel/core': 7.24.7 '@babel/helper-define-polyfill-provider': 0.6.2(@babel/core@7.24.7) semver: 6.3.1 @@ -10073,8 +10073,6 @@ snapshots: '@esbuild/win32-ia32': 0.21.5 '@esbuild/win32-x64': 0.21.5 - escalade@3.1.1: {} - escalade@3.1.2: {} escape-html@1.0.3: {} @@ -11241,7 +11239,7 @@ snapshots: dependencies: hosted-git-info: 2.8.9 resolve: 1.22.2 - semver: 5.7.1 + semver: 5.7.2 validate-npm-package-license: 3.0.4 normalize-path@3.0.0: {} @@ -12736,13 +12734,13 @@ snapshots: update-browserslist-db@1.0.13(browserslist@4.22.3): dependencies: browserslist: 4.22.3 - escalade: 3.1.1 + escalade: 3.1.2 picocolors: 1.0.0 update-browserslist-db@1.0.13(browserslist@4.23.0): dependencies: browserslist: 4.23.0 - escalade: 3.1.1 + escalade: 3.1.2 picocolors: 1.0.0 update-browserslist-db@1.1.0(browserslist@4.23.1): @@ -12995,7 +12993,7 @@ snapshots: yargs@17.7.1: dependencies: cliui: 8.0.1 - escalade: 3.1.1 + escalade: 3.1.2 get-caller-file: 2.0.5 require-directory: 2.1.1 string-width: 4.2.3 diff --git a/scripts/build-copy.cjs b/scripts/build-copy.cjs deleted file mode 100644 index 77f3fc17..00000000 --- a/scripts/build-copy.cjs +++ /dev/null @@ -1,71 +0,0 @@ -const fs = require("node:fs"); -const path = require("node:path"); -const pck = require("../package"); -const rootDir = path.resolve(__dirname, "../"); -const distDir = path.resolve(__dirname, "../dist"); - -const filesToCopy = ["package.json", "README.md", "LICENSE"]; -filesToCopy.forEach((file) => { - fs.copyFileSync(path.resolve(rootDir, file), path.resolve(distDir, file)); -}); - -const packageFieldsToRemove = [ - "private", - "devDependencies", - "optionalDependencies", - "packageManager", - "engines", - "lint-staged", - "scripts", - "husky", - "simple-git-hooks", - "prettier", - "jest", - "eslintConfig", - "eslintIgnore", - "np", - "release", - "size-limit", -]; - -packageFieldsToRemove.forEach((field) => { - delete pck[field]; -}); - -// Remove 'dist' from the files inside the 'dist' dir, after we move them -const fields = [ - "main", - "module", - "unpkg", - "exports", - "esmodule", - "exports", - "types", - "typings", -]; -fields.forEach((key) => { - if (typeof pck[key] === "object") { - const keys = Object.keys(pck[key]); - keys.forEach((subkey) => { - if (typeof pck[key][subkey] === "string") { - pck[key][subkey] = pck[key][subkey]?.replace("./dist/", "./"); - } else if (typeof pck[key][subkey] === "object") { - const sub = pck[key][subkey]; - const subkeys = Object.keys(sub); - subkeys.forEach((subsubkey) => { - if (typeof sub[subsubkey] === "string") { - sub[subsubkey] = sub[subsubkey]?.replace("./dist/", "./"); - } - }); - } - }); - } else { - pck[key] = pck[key]?.replace("./dist/", "./"); - } -}); - -fs.writeFileSync( - path.resolve(distDir, "package.json"), - JSON.stringify(pck, undefined, 2), - "utf-8", -); diff --git a/src/test-utils.ts b/src/test-utils.ts index edfb6791..e5da09d4 100644 --- a/src/test-utils.ts +++ b/src/test-utils.ts @@ -58,7 +58,7 @@ afterEach(() => { * Create a custom IntersectionObserver mock, allowing us to intercept the `observe` and `unobserve` calls. * We keep track of the elements being observed, so when `mockAllIsIntersecting` is triggered it will * know which elements to trigger the event on. - * @param mockFn The mock function to use. Defaults to `jest.fn`. + * @param mockFn The mock function to use. Defaults to `vi.fn`. */ export function setupIntersectionMocking(mockFn: typeof jest.fn) { global.IntersectionObserver = mockFn((cb, options = {}) => {