diff --git a/components/react/build.js b/components/react/build.js index 63c48c7..b3a6308 100644 --- a/components/react/build.js +++ b/components/react/build.js @@ -13,6 +13,8 @@ const compile = { dist: true, // Generate TypeScript definitions in dist api: true, + // Clean up + cleanup: true, }; process.argv.slice(2).forEach((cmd) => { diff --git a/components/react/cleanup.js b/components/react/cleanup.js new file mode 100644 index 0000000..f6c40f0 --- /dev/null +++ b/components/react/cleanup.js @@ -0,0 +1,21 @@ +/* eslint-disable */ +const { readFileSync, writeFileSync } = require('fs'); + +// Text to ad +const text = "'use client'"; + +// List of files to fix +['iconify', 'offline'].forEach((prefix) => { + ['js', 'cjs', 'mjs'].forEach((ext) => { + const file = `dist/${prefix}.${ext}`; + try { + const content = readFileSync(file, 'utf8'); + if (!content.startsWith(text)) { + writeFileSync(file, text + '\n\n' + content, 'utf8'); + console.log('Added client only statement to ' + file); + } + } catch { + // + } + }); +}); diff --git a/components/react/package.json b/components/react/package.json index ac0b0f5..ecf0488 100644 --- a/components/react/package.json +++ b/components/react/package.json @@ -2,7 +2,7 @@ "name": "@iconify/react", "description": "Iconify icon component for React.", "author": "Vjacheslav Trushkin", - "version": "5.0.0-beta.2", + "version": "5.0.0-beta.3", "publishConfig": { "access": "public", "tag": "next" @@ -24,6 +24,7 @@ "build:dist": "rollup -c rollup.config.mjs", "prebuild:api": "api-extractor run --local --verbose --config api-extractor.offline.json", "build:api": "api-extractor run --local --verbose --config api-extractor.iconify.json", + "build:cleanup": "node cleanup", "test": "jest --runInBand" }, "main": "dist/iconify.js",