diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index 686595e..1eb8fb5 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.CI_USER_TOKEN || secrets.GITHUB_TOKEN }} repository: 'optimizely/travisci-tools' diff --git a/.github/workflows/react.yml b/.github/workflows/react.yml index a7df4bb..1fc14dd 100644 --- a/.github/workflows/react.yml +++ b/.github/workflows/react.yml @@ -15,13 +15,14 @@ jobs: node: [ '18', '20', '22', '24' ] steps: - name: Checkout branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node ${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + cache: 'npm' - name: Install dependencies - run: npm install + run: npm ci - name: Run tests run: npm test @@ -30,11 +31,11 @@ jobs: runs-on: ubuntu-latest needs: [ unitTests ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ArtiomTr/jest-coverage-report-action@v2 with: custom-title: 'Jest Coverage Report' - package-manager: 'yarn' + package-manager: 'npm' integration_tests: name: Run integration tests diff --git a/.github/workflows/react_release.yml b/.github/workflows/react_release.yml index 1bbf04d..2b02c46 100644 --- a/.github/workflows/react_release.yml +++ b/.github/workflows/react_release.yml @@ -13,16 +13,17 @@ jobs: uses: actions/checkout@v4 - name: Set up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: "https://registry.npmjs.org/" always-auth: "true" + cache: 'npm' env: NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_REACT_TO_NPM_FROM_GITHUB }} - name: Install dependencies - run: npm install + run: npm ci - id: npm-tag name: Determine NPM tag diff --git a/package-lock.json b/package-lock.json index 8136443..bf7f629 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,10 +13,10 @@ "hoist-non-react-statics": "^3.3.2" }, "devDependencies": { - "@rollup/plugin-commonjs": "^26.0.1", - "@rollup/plugin-node-resolve": "^15.2.3", - "@rollup/plugin-replace": "^5.0.7", - "@rollup/plugin-terser": "0.4.2", + "@rollup/plugin-commonjs": "^29.0.0", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-replace": "^6.0.3", + "@rollup/plugin-terser": "^0.4.4", "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^14.3.0", "@types/hoist-non-react-statics": "^3.3.5", @@ -37,10 +37,10 @@ "prettier": "^3.3.3", "react": "^18.3.0", "react-dom": "^18.3.0", - "rollup": "^3.29.4", + "rollup": "^4.55.1", "rollup-plugin-typescript2": "^0.36.0", "ts-jest": "^29.2.3", - "typescript": "^5.5.4" + "typescript": "^5.9.3" }, "engines": { "node": ">=18.0.0" @@ -1595,18 +1595,19 @@ } }, "node_modules/@rollup/plugin-commonjs": { - "version": "26.0.3", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-26.0.3.tgz", - "integrity": "sha512-2BJcolt43MY+y5Tz47djHkodCC3c1VKVrBDKpVqHKpQ9z9S158kCCqB8NF6/gzxLdNlYW9abB3Ibh+kOWLp8KQ==", + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-29.0.0.tgz", + "integrity": "sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==", "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.0.1", "commondir": "^1.0.1", "estree-walker": "^2.0.2", - "glob": "^10.4.1", + "fdir": "^6.2.0", "is-reference": "1.2.1", - "magic-string": "^0.30.3" + "magic-string": "^0.30.3", + "picomatch": "^4.0.2" }, "engines": { "node": ">=16.0.0 || 14 >= 14.17" @@ -1621,9 +1622,9 @@ } }, "node_modules/@rollup/plugin-node-resolve": { - "version": "15.3.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.1.tgz", - "integrity": "sha512-tgg6b91pAybXHJQMAAwW9VuWBO6Thi+q7BCNARLwSqlmsHz0XYURtGvh/AuwSADXSI4h/2uHbs7s4FzlZDGSGA==", + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", + "integrity": "sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==", "dev": true, "license": "MIT", "dependencies": { @@ -1646,9 +1647,9 @@ } }, "node_modules/@rollup/plugin-replace": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-5.0.7.tgz", - "integrity": "sha512-PqxSfuorkHz/SPpyngLyg5GCEkOcee9M1bkxiVDr41Pd61mqP1PLOoDPbpl44SB2mQGKwV/In74gqQmGITOhEQ==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.3.tgz", + "integrity": "sha512-J4RZarRvQAm5IF0/LwUUg+obsm+xZhYnbMXmXROyoSE1ATJe3oXSb9L5MMppdxP2ylNSjv6zFBwKYjcKMucVfA==", "dev": true, "license": "MIT", "dependencies": { @@ -1668,21 +1669,21 @@ } }, "node_modules/@rollup/plugin-terser": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.2.tgz", - "integrity": "sha512-jfUVQ4MxzIB0mz8QhDA1xiLT+pTF3WEWXeIqcwhoF84WhLWscPpxjJgjYMyAq0Po4UXqw2D9C64tD0gRDzJzfA==", + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", "dev": true, "license": "MIT", "dependencies": { - "serialize-javascript": "^6.0.0", - "smob": "^0.0.6", - "terser": "^5.15.1" + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" }, "engines": { "node": ">=14.0.0" }, "peerDependencies": { - "rollup": "^2.x || ^3.x" + "rollup": "^2.0.0||^3.0.0||^4.0.0" }, "peerDependenciesMeta": { "rollup": { @@ -1713,6 +1714,356 @@ } } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.55.1.tgz", + "integrity": "sha512-9R0DM/ykwfGIlNu6+2U09ga0WXeZ9MRC2Ter8jnz8415VbuIykVuc6bhdrbORFZANDmTDvq26mJrEVTl8TdnDg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.55.1.tgz", + "integrity": "sha512-eFZCb1YUqhTysgW3sj/55du5cG57S7UTNtdMjCW7LwVcj3dTTcowCsC8p7uBdzKsZYa8J7IDE8lhMI+HX1vQvg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.55.1.tgz", + "integrity": "sha512-p3grE2PHcQm2e8PSGZdzIhCKbMCw/xi9XvMPErPhwO17vxtvCN5FEA2mSLgmKlCjHGMQTP6phuQTYWUnKewwGg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.55.1.tgz", + "integrity": "sha512-rDUjG25C9qoTm+e02Esi+aqTKSBYwVTaoS1wxcN47/Luqef57Vgp96xNANwt5npq9GDxsH7kXxNkJVEsWEOEaQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.55.1.tgz", + "integrity": "sha512-+JiU7Jbp5cdxekIgdte0jfcu5oqw4GCKr6i3PJTlXTCU5H5Fvtkpbs4XJHRmWNXF+hKmn4v7ogI5OQPaupJgOg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.55.1.tgz", + "integrity": "sha512-V5xC1tOVWtLLmr3YUk2f6EJK4qksksOYiz/TCsFHu/R+woubcLWdC9nZQmwjOAbmExBIVKsm1/wKmEy4z4u4Bw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.55.1.tgz", + "integrity": "sha512-Rn3n+FUk2J5VWx+ywrG/HGPTD9jXNbicRtTM11e/uorplArnXZYsVifnPPqNNP5BsO3roI4n8332ukpY/zN7rQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.55.1.tgz", + "integrity": "sha512-grPNWydeKtc1aEdrJDWk4opD7nFtQbMmV7769hiAaYyUKCT1faPRm2av8CX1YJsZ4TLAZcg9gTR1KvEzoLjXkg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.55.1.tgz", + "integrity": "sha512-a59mwd1k6x8tXKcUxSyISiquLwB5pX+fJW9TkWU46lCqD/GRDe9uDN31jrMmVP3feI3mhAdvcCClhV8V5MhJFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.55.1.tgz", + "integrity": "sha512-puS1MEgWX5GsHSoiAsF0TYrpomdvkaXm0CofIMG5uVkP6IBV+ZO9xhC5YEN49nsgYo1DuuMquF9+7EDBVYu4uA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.55.1.tgz", + "integrity": "sha512-r3Wv40in+lTsULSb6nnoudVbARdOwb2u5fpeoOAZjFLznp6tDU8kd+GTHmJoqZ9lt6/Sys33KdIHUaQihFcu7g==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.55.1.tgz", + "integrity": "sha512-MR8c0+UxAlB22Fq4R+aQSPBayvYa3+9DrwG/i1TKQXFYEaoW3B5b/rkSRIypcZDdWjWnpcvxbNaAJDcSbJU3Lw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.55.1.tgz", + "integrity": "sha512-3KhoECe1BRlSYpMTeVrD4sh2Pw2xgt4jzNSZIIPLFEsnQn9gAnZagW9+VqDqAHgm1Xc77LzJOo2LdigS5qZ+gw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.55.1.tgz", + "integrity": "sha512-ziR1OuZx0vdYZZ30vueNZTg73alF59DicYrPViG0NEgDVN8/Jl87zkAPu4u6VjZST2llgEUjaiNl9JM6HH1Vdw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.55.1.tgz", + "integrity": "sha512-uW0Y12ih2XJRERZ4jAfKamTyIHVMPQnTZcQjme2HMVDAHY4amf5u414OqNYC+x+LzRdRcnIG1YodLrrtA8xsxw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.55.1.tgz", + "integrity": "sha512-u9yZ0jUkOED1BFrqu3BwMQoixvGHGZ+JhJNkNKY/hyoEgOwlqKb62qu+7UjbPSHYjiVy8kKJHvXKv5coH4wDeg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.55.1.tgz", + "integrity": "sha512-/0PenBCmqM4ZUd0190j7J0UsQ/1nsi735iPRakO8iPciE7BQ495Y6msPzaOmvx0/pn+eJVVlZrNrSh4WSYLxNg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.55.1.tgz", + "integrity": "sha512-a8G4wiQxQG2BAvo+gU6XrReRRqj+pLS2NGXKm8io19goR+K8lw269eTrPkSdDTALwMmJp4th2Uh0D8J9bEV1vg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.55.1.tgz", + "integrity": "sha512-bD+zjpFrMpP/hqkfEcnjXWHMw5BIghGisOKPj+2NaNDuVT+8Ds4mPf3XcPHuat1tz89WRL+1wbcxKY3WSbiT7w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.55.1.tgz", + "integrity": "sha512-eLXw0dOiqE4QmvikfQ6yjgkg/xDM+MdU9YJuP4ySTibXU0oAvnEWXt7UDJmD4UkYialMfOGFPJnIHSe/kdzPxg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.55.1.tgz", + "integrity": "sha512-xzm44KgEP11te3S2HCSyYf5zIzWmx3n8HDCc7EE59+lTcswEWNpvMLfd9uJvVX8LCg9QWG67Xt75AuHn4vgsXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.55.1.tgz", + "integrity": "sha512-yR6Bl3tMC/gBok5cz/Qi0xYnVbIxGx5Fcf/ca0eB6/6JwOY+SRUcJfI0OpeTpPls7f194as62thCt/2BjxYN8g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.55.1.tgz", + "integrity": "sha512-3fZBidchE0eY0oFZBnekYCfg+5wAB0mbpCBuofh5mZuzIU/4jIVkbESmd2dOsFNS78b53CYv3OAtwqkZZmU5nA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.55.1.tgz", + "integrity": "sha512-xGGY5pXj69IxKb4yv/POoocPy/qmEGhimy/FoTpTSVju3FYXUQQMFCaZZXJVidsmGxRioZAwpThl/4zX41gRKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.55.1.tgz", + "integrity": "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@sinclair/typebox": { "version": "0.34.41", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.41.tgz", @@ -8613,19 +8964,47 @@ } }, "node_modules/rollup": { - "version": "3.29.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.5.tgz", - "integrity": "sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==", + "version": "4.55.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.55.1.tgz", + "integrity": "sha512-wDv/Ht1BNHB4upNbK74s9usvl7hObDnvVzknxqY/E/O3X6rW1U1rV1aENEfJ54eFZDTNo7zv1f5N4edCluH7+A==", "dev": true, "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, "bin": { "rollup": "dist/bin/rollup" }, "engines": { - "node": ">=14.18.0", + "node": ">=18.0.0", "npm": ">=8.0.0" }, "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.55.1", + "@rollup/rollup-android-arm64": "4.55.1", + "@rollup/rollup-darwin-arm64": "4.55.1", + "@rollup/rollup-darwin-x64": "4.55.1", + "@rollup/rollup-freebsd-arm64": "4.55.1", + "@rollup/rollup-freebsd-x64": "4.55.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.55.1", + "@rollup/rollup-linux-arm-musleabihf": "4.55.1", + "@rollup/rollup-linux-arm64-gnu": "4.55.1", + "@rollup/rollup-linux-arm64-musl": "4.55.1", + "@rollup/rollup-linux-loong64-gnu": "4.55.1", + "@rollup/rollup-linux-loong64-musl": "4.55.1", + "@rollup/rollup-linux-ppc64-gnu": "4.55.1", + "@rollup/rollup-linux-ppc64-musl": "4.55.1", + "@rollup/rollup-linux-riscv64-gnu": "4.55.1", + "@rollup/rollup-linux-riscv64-musl": "4.55.1", + "@rollup/rollup-linux-s390x-gnu": "4.55.1", + "@rollup/rollup-linux-x64-gnu": "4.55.1", + "@rollup/rollup-linux-x64-musl": "4.55.1", + "@rollup/rollup-openbsd-x64": "4.55.1", + "@rollup/rollup-openharmony-arm64": "4.55.1", + "@rollup/rollup-win32-arm64-msvc": "4.55.1", + "@rollup/rollup-win32-ia32-msvc": "4.55.1", + "@rollup/rollup-win32-x64-gnu": "4.55.1", + "@rollup/rollup-win32-x64-msvc": "4.55.1", "fsevents": "~2.3.2" } }, @@ -9036,9 +9415,9 @@ } }, "node_modules/smob": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/smob/-/smob-0.0.6.tgz", - "integrity": "sha512-V21+XeNni+tTyiST1MHsa84AQhT1aFZipzPpOFAVB8DkHzwJyjjAmt9bgwnuZiZWnIbMo2duE29wybxv/7HWUw==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", + "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index 87e4a0a..69682da 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,17 @@ "homepage": "https://github.com/optimizely/react-sdk", "repository": "https://github.com/optimizely/react-sdk", "license": "Apache-2.0", - "module": "dist/react-sdk.es.js", - "types": "dist/index.d.ts", - "main": "dist/react-sdk.js", - "browser": "dist/react-sdk.js", - "directories": { - "lib": "lib" + "main": "./dist/react-sdk.min.js", + "module": "./dist/react-sdk.es.min.js", + "browser": "./dist/react-sdk.es.min.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/react-sdk.es.min.js", + "require": "./dist/react-sdk.min.js", + "default": "./dist/react-sdk.min.js" + } }, "files": [ "dist", @@ -22,9 +27,12 @@ "node": ">=18.0.0" }, "scripts": { - "tsc": "rm -rf lib/ && tsc", - "build": "rm -rf dist/ && node ./scripts/build.js", - "build:win": "(if exist dist rd /s/q dist) && node ./scripts/winbuild.js", + "clean": "rm -rf dist", + "clean:win": "(if exist dist rd /s/q dist)", + "prebuild": "npm run clean", + "build": "tsc --noEmit && rollup -c", + "build:win": "npm run clean:win && tsc --noEmit && rollup -c", + "build-umd": "rollup -c --config-umd", "lint": "tsc --noEmit && eslint 'src/**/*.{js,ts,tsx}' --fix", "test": "jest --silent", "test-coverage": "jest --coverage --coverageReporters=\"text-summary\" --silent", @@ -35,9 +43,9 @@ "access": "public" }, "lint-staged": { - "**/*.{js,ts,tsx}": [ + "src/**/*.{js,ts,tsx}": [ "npm run lint", - "npm run test --findRelatedTests" + "npm run test -- --findRelatedTests --passWithNoTests" ] }, "dependencies": { @@ -48,10 +56,10 @@ "react": ">=16.8.0" }, "devDependencies": { - "@rollup/plugin-commonjs": "^26.0.1", - "@rollup/plugin-node-resolve": "^15.2.3", - "@rollup/plugin-replace": "^5.0.7", - "@rollup/plugin-terser": "0.4.2", + "@rollup/plugin-commonjs": "^29.0.0", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-replace": "^6.0.3", + "@rollup/plugin-terser": "^0.4.4", "@testing-library/jest-dom": "^6.4.8", "@testing-library/react": "^14.3.0", "@types/hoist-non-react-statics": "^3.3.5", @@ -72,9 +80,9 @@ "prettier": "^3.3.3", "react": "^18.3.0", "react-dom": "^18.3.0", - "rollup": "^3.29.4", + "rollup": "^4.55.1", "rollup-plugin-typescript2": "^0.36.0", "ts-jest": "^29.2.3", - "typescript": "^5.5.4" + "typescript": "^5.9.3" } } diff --git a/rollup.config.mjs b/rollup.config.mjs new file mode 100644 index 0000000..34815b5 --- /dev/null +++ b/rollup.config.mjs @@ -0,0 +1,105 @@ +/** + * Copyright 2026 Optimizely + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import commonjs from '@rollup/plugin-commonjs'; +import resolve from '@rollup/plugin-node-resolve'; +import replace from '@rollup/plugin-replace'; +import terser from '@rollup/plugin-terser'; +import typescript from 'rollup-plugin-typescript2'; +import pkg from './package.json' with { type: 'json' }; + +const { dependencies, peerDependencies } = pkg; +const external = [...Object.keys(dependencies || {}), ...Object.keys(peerDependencies || {}), 'crypto']; + +const typescriptPluginOptions = { + exclude: ['./dist', '**/*.spec.ts', '**/*.spec.tsx'], + include: ['./src/**/*.ts', './src/**/*.tsx'], +}; + +const cjsBundle = (minify = true) => ({ + input: 'src/index.ts', + external, + plugins: [resolve({ browser: true }), commonjs(), typescript(typescriptPluginOptions), minify && terser()].filter( + Boolean + ), + output: { + file: `dist/react-sdk${minify ? '.min' : ''}.js`, + format: 'cjs', + exports: 'named', + sourcemap: true, + globals: { react: 'React' }, + }, +}); + +const esmBundle = (minify = true) => ({ + input: 'src/index.ts', + external, + plugins: [resolve({ browser: true }), commonjs(), typescript(typescriptPluginOptions), minify && terser()].filter( + Boolean + ), + output: { + file: `dist/react-sdk.es${minify ? '.min' : ''}.js`, + format: 'es', + sourcemap: true, + }, +}); + +const umdBundle = (minify = true) => ({ + input: 'src/index.ts', + external: ['react'], + plugins: [ + resolve({ browser: true }), + commonjs(), + replace({ + 'process.env.NODE_ENV': JSON.stringify('production'), + preventAssignment: true, + }), + typescript(typescriptPluginOptions), + minify && terser(), + ].filter(Boolean), + output: { + file: `dist/react-sdk.umd${minify ? '.min' : ''}.js`, + format: 'umd', + name: 'optimizelyReactSdk', + exports: 'named', + sourcemap: true, + globals: { react: 'React' }, + }, +}); + +const bundles = { + 'cjs-min': cjsBundle(true), + cjs: cjsBundle(false), + 'esm-min': esmBundle(true), + esm: esmBundle(false), + 'umd-min': umdBundle(true), + umd: umdBundle(false), +}; + +export default (args) => { + const patterns = Object.keys(args) + .filter((arg) => arg.startsWith('config-')) + .map((arg) => arg.replace(/config-/, '')); + + if (!patterns.length) { + // Default: build minified versions only + return [bundles['cjs-min'], bundles['esm-min'], bundles['umd-min']]; + } + + return Object.entries(bundles) + .filter(([name]) => patterns.some((pattern) => name.match(pattern))) + .map(([, config]) => config); +}; diff --git a/scripts/build.js b/scripts/build.js deleted file mode 100644 index 11e6859..0000000 --- a/scripts/build.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2019, 2023 Optimizely - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const path = require('path'); -const execSync = require('child_process').execSync; - -process.chdir(path.resolve(__dirname, '..')); - -function exec(command, extraEnv) { - return execSync(command, { - stdio: 'inherit', - env: Object.assign({}, process.env, extraEnv), - }); -} - -const packageName = 'react-sdk'; -const umdName = 'optimizelyReactSdk'; - -console.log('\nBuilding ES modules...'); -exec(`./node_modules/.bin/rollup -c scripts/config.js -f es -o dist/${packageName}.es.js`); - -console.log('\nBuilding CommonJS modules...'); -exec(`./node_modules/.bin/rollup -c scripts/config.js -f cjs -o dist/${packageName}.js`); - -console.log('\nBuilding UMD modules...'); -exec(`./node_modules/.bin/rollup -c scripts/config.js -f umd -o dist/${packageName}.umd.js --name ${umdName}`, { - EXTERNALS: 'forBrowsers', - BUILD_ENV: 'production', -}); - -console.log('\nBuilding SystemJS modules...'); -exec(`./node_modules/.bin/rollup -c scripts/config.js -f system -o dist/${packageName}.system.js`, { - EXTERNALS: 'forBrowsers', - BUILD_ENV: 'production', -}); diff --git a/scripts/config.js b/scripts/config.js deleted file mode 100644 index f939b65..0000000 --- a/scripts/config.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2019, 2023 Optimizely - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const typescript = require('rollup-plugin-typescript2'); -const commonjs = require('@rollup/plugin-commonjs'); -const replace = require('@rollup/plugin-replace'); -const { nodeResolve } = require('@rollup/plugin-node-resolve'); -const terser = require('@rollup/plugin-terser'); - -const packageDeps = require('../package.json').dependencies || {}; -const packagePeers = require('../package.json').peerDependencies || {}; - -function getExternals(externals) { - let externalLibs; - if (externals === 'forBrowsers') { - externalLibs = ['react']; - } else { - externalLibs = - externals === 'peers' ? Object.keys(packagePeers) : Object.keys(packageDeps).concat(Object.keys(packagePeers)); - } - externalLibs.push('crypto'); - return externalLibs; -} - -function getPlugins(env, externals) { - const plugins = [ - nodeResolve({ - browser: externals === 'forBrowsers', - preferBuiltins: externals !== 'forBrowsers', - }), - commonjs({ - include: /node_modules/, - }), - ]; - - if (env) { - plugins.push( - replace({ - 'process.env.NODE_ENV': JSON.stringify(env), - preventAssignment: false, - }) - ); - } - - plugins.push(typescript()); - - if (env === 'production') { - plugins.push(terser()); - } - - return plugins; -} - -const config = { - input: 'src/index.ts', - output: { - globals: { - react: 'React', - crypto: 'crypto', - }, - }, - external: getExternals(process.env.EXTERNALS), - plugins: getPlugins(process.env.BUILD_ENV, process.env.EXTERNALS), -}; - -module.exports = config; diff --git a/scripts/winbuild.js b/scripts/winbuild.js deleted file mode 100644 index 25bbdd8..0000000 --- a/scripts/winbuild.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2023, Optimizely - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const path = require('path'); -const execSync = require('child_process').execSync; - -process.chdir(path.resolve(__dirname, '..')); - -function exec(command, extraEnv) { - return execSync(command, { - stdio: 'inherit', - env: Object.assign({}, process.env, extraEnv), - }); -} - -const packageName = 'react-sdk'; -const umdName = 'optimizelyReactSdk'; - -console.log('\nBuilding ES modules...'); -exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f es -o dist\\${packageName}.es.js`); - -console.log('\nBuilding CommonJS modules...'); - -exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f cjs -o dist\\${packageName}.js`); - -console.log('\nBuilding UMD modules...'); - -exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f umd -o dist\\${packageName}.umd.js --name ${umdName}`, { - EXTERNALS: 'forBrowsers', - BUILD_ENV: 'production', -}); - -console.log('\nBuilding SystemJS modules...'); - -exec(`.\\node_modules\\.bin\\rollup -c scripts\\config.js -f system -o dist\\${packageName}.system.js`, { - EXTERNALS: 'forBrowsers', - BUILD_ENV: 'production', -}); diff --git a/src/Experiment.tsx b/src/Experiment.tsx index 846201d..daaa113 100644 --- a/src/Experiment.tsx +++ b/src/Experiment.tsx @@ -61,6 +61,7 @@ const Experiment: React.FunctionComponent = (props) => { // We use React.Children.forEach instead of React.Children.toArray().find() // here because toArray adds keys to all child elements and we do not want // to trigger an unmount/remount + // @ts-ignore React.Children.forEach(children, (child: React.ReactElement) => { if (!React.isValidElement(child)) { return; diff --git a/tsconfig.json b/tsconfig.json index 6b38846..fe57f0a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,22 +1,21 @@ { "compilerOptions": { + "target": "ES6", + "module": "ESNext", + "lib": ["ES6", "DOM"], "declaration": true, - "target": "es5", - "lib": ["es2015", "dom"], - "jsx": "react", - "moduleResolution": "node", - "noImplicitReturns": true, + "strict": true, "noImplicitThis": true, - "noImplicitAny": true, - "strictNullChecks": true, - "noLib": false, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "sourceMap": true, + "noImplicitReturns": true, + "moduleResolution": "node", + "esModuleInterop": true, + "resolveJsonModule": true, + "outDir": "./dist", "declarationDir": "./dist", - "outDir": "./lib", - "esModuleInterop": true + "sourceMap": true, + "skipLibCheck": true, + "jsx": "react" }, - "include": ["./src"], - "exclude": ["./node_modules", "./src/**/*.spec.tsx", "./src/**/*.spec.ts"] - } + "include": ["./src/**/*.ts", "./src/**/*.tsx"], + "exclude": ["./dist", "./node_modules", "**/*.spec.ts", "**/*.spec.tsx"] +}