diff --git a/.circleci/config.yml b/.circleci/config.yml index 8fd92ac..392da60 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -109,6 +109,8 @@ commands: name: Yarn Install command: | yarn install --frozen-lockfile --no-progress --non-interactive --cache-folder ~/.cache/yarn + cd ~/react-native-url-polyfill && yarn prepublishOnly + install-detox: steps: - restore-cache-detox-env diff --git a/index.js b/index.js index 71611b2..6322dff 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,10 @@ import './js/ios10Fix'; -import packageJson from './package.json'; - export * from './js/URL'; export * from './js/URLSearchParams'; export function setupURLPolyfill() { - globalThis.REACT_NATIVE_URL_POLYFILL = `${packageJson.name}@${packageJson.version}`; + globalThis.REACT_NATIVE_URL_POLYFILL = ''; globalThis.URL = require('./js/URL').URL; globalThis.URLSearchParams = require('./js/URLSearchParams').URLSearchParams; diff --git a/package.json b/package.json index 206937e..a9835a4 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "lint": "eslint .", "type-check": "tsc index.d.ts", "prepare": "husky install", + "prepublishOnly": "node scripts/prepublish", "bundle-size": "node scripts/bundle-size" }, "author": "Nicolas Charpentier ", diff --git a/scripts/prepublish.js b/scripts/prepublish.js new file mode 100644 index 0000000..1c57ef9 --- /dev/null +++ b/scripts/prepublish.js @@ -0,0 +1,12 @@ +#!/usr/bin/node +const fs = require('node:fs'); + +const packageJson = require('../package.json'); +const path = require.resolve('../index.js'); + +fs.writeFileSync( + path, + fs + .readFileSync(path, 'utf8') + .replace('', `${packageJson.name}@${packageJson.version}`), +);