2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-04 18:23:17 +00:00

chore(react): convert to esm

This commit is contained in:
Vjacheslav Trushkin 2024-05-28 22:20:42 +03:00
parent e00aaef254
commit e4284778e9
5 changed files with 20 additions and 27 deletions

View File

@ -1,6 +1,5 @@
/* eslint-disable */
const fs = require('fs');
const child_process = require('child_process');
import { statSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
// List of commands to run
const commands = [];
@ -52,7 +51,7 @@ process.argv.slice(2).forEach((cmd) => {
// Check if required modules in same monorepo are available
const fileExists = (file) => {
try {
fs.statSync(file);
statSync(file);
} catch (e) {
return false;
}
@ -86,11 +85,7 @@ const next = () => {
process.exit(0);
}
if (item.cwd === void 0) {
item.cwd = __dirname;
}
const result = child_process.spawnSync(item.cmd, item.args, {
const result = spawnSync(item.cmd, item.args, {
cwd: item.cwd,
stdio: 'inherit',
});

View File

@ -1,5 +1,4 @@
/* eslint-disable */
const { readFileSync, writeFileSync } = require('fs');
import { readFileSync, writeFileSync } from 'node:fs';
// Text to ad
const text = "'use client'";
@ -12,7 +11,7 @@ const text = "'use client'";
try {
const content = readFileSync(file, 'utf8');
if (!content.startsWith(text)) {
writeFileSync(file, text + '\n\n' + content, 'utf8');
writeFileSync(file, text + ';\n\n' + content, 'utf8');
console.log('Added client only statement to ' + file);
}
} catch {
@ -22,6 +21,6 @@ const text = "'use client'";
// Copy .d.ts to .d.mts
const source = `dist/${prefix}.d.ts`;
const target = `dist/${prefix}.d.mts`;
const target = `dist/${prefix}.d.cts`;
writeFileSync(target, readFileSync(source, 'utf8'), 'utf8');
});

View File

@ -2,12 +2,11 @@
"name": "@iconify/react/offline",
"main": "../dist/offline.js",
"types": "../dist/offline.d.ts",
"module": "../dist/offline.mjs",
"exports": {
"./*": "./*",
".": {
"require": "../dist/offline.js",
"import": "../dist/offline.mjs",
"require": "../dist/offline.cjs",
"import": "../dist/offline.js",
"types": "../dist/offline.d.ts",
"default": "../dist/offline.js"
}

View File

@ -2,7 +2,8 @@
"name": "@iconify/react",
"description": "Iconify icon component for React.",
"author": "Vjacheslav Trushkin",
"version": "5.0.0-beta.5",
"type": "module",
"version": "5.0.0-beta.6",
"publishConfig": {
"access": "public",
"tag": "next"
@ -21,32 +22,31 @@
"prebuild": "pnpm run clean",
"build": "node build",
"build:lib": "tsc -b",
"build:dist": "rollup -c rollup.config.mjs",
"build:dist": "rollup -c rollup.config.js",
"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",
"module": "dist/iconify.mjs",
"types": "dist/iconify.d.ts",
"exports": {
"./*": "./*",
".": {
"require": "./dist/iconify.js",
"import": "./dist/iconify.mjs",
"require": "./dist/iconify.cjs",
"import": "./dist/iconify.js",
"types": "./dist/iconify.d.ts",
"default": "./dist/iconify.js"
},
"./offline": {
"require": "./dist/offline.js",
"import": "./dist/offline.mjs",
"require": "./dist/offline.cjs",
"import": "./dist/offline.js",
"types": "./dist/offline.d.ts",
"default": "./dist/offline.js"
},
"./dist/offline": {
"require": "./dist/offline.js",
"import": "./dist/offline.mjs",
"require": "./dist/offline.cjs",
"import": "./dist/offline.js",
"types": "./dist/offline.d.ts",
"default": "./dist/offline.js"
}

View File

@ -11,7 +11,7 @@ names.forEach((name) => {
input: `lib/${name}.js`,
output: [
{
file: `dist/${name}.mjs`,
file: `dist/${name}.js`,
format: 'esm',
},
],
@ -24,7 +24,7 @@ names.forEach((name) => {
input: `lib/${name}.js`,
output: [
{
file: `dist/${name}.js`,
file: `dist/${name}.cjs`,
format: 'cjs',
},
],