Skip to content

Commit

Permalink
Merge pull request #14 from MiracleUFO/fix-build/build-error
Browse files Browse the repository at this point in the history
Fix build/build error
  • Loading branch information
MiracleUFO authored Oct 5, 2023
2 parents 9eaa28e + ee6b6df commit 878d2cd
Show file tree
Hide file tree
Showing 6 changed files with 1,600 additions and 608 deletions.
2,057 changes: 1,477 additions & 580 deletions package-lock.json

Large diffs are not rendered by default.

58 changes: 34 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,20 @@
"name": "@miracleufo/react-g-translator",
"version": "1.0.0",
"description": "A modern, free, lightweight npm package for translating react apps (component wrapper.) No API keys or language list files are required.",
"exports": {
".": {
"import": {
"types": "./lib/esm/types/index.d.ts",
"default": "./lib/esm/index.mjs"
},
"require": {
"types": "./lib/cjs/types/index.d.ts",
"default": "./lib/cjs/index.js"
}
}
},
"types": "./lib/cjs/types/index.d.ts",
"main": "./lib/cjs/index.js",
"author": "Miracle Ufodiama",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"unpkg": "dist/index.min.js",
"types": "dist/index.d.ts",
"files": [
"lib/**/*"
"dist",
"src",
"tsconfig.json"
],
"scripts": {
"clean": "rm -rf ./lib",
"build": "npm run clean && npm run build:esm && npm run build:cjs",
"build:esm": "tsc -p ./configs/tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs",
"build:cjs": "tsc -p ./configs/tsconfig.cjs.json",
"clean": "rimraf dist",
"build": "npm run clean && rollup -c",
"semantic-release": "semantic-release",
"test": "env-cmd -f .env.development react-scripts test --runInBand --no-cache",
"prepack": "npm run build",
Expand All @@ -47,17 +39,25 @@
"typescript",
"esm",
"cjs",
"umd",
"react",
"nodejs",
"commonjs",
"ecmascript",
"beginner",
"example",
"demonstration"
"demonstration",
"localisation",
"accessibility",
"a11y",
"internationalisation",
"i18n"
],
"author": "Miracle Ufodiama",
"license": "MIT",
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@rollup/plugin-commonjs": "^25.0.5",
"@rollup/plugin-json": "^6.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@types/crypto-js": "^4.1.2",
"@types/google-translate-api": "^2.3.2",
"@types/jest": "^29.5.4",
Expand All @@ -83,6 +83,11 @@
"jsdom": "20.0.3",
"jsdom-global": "3.0.2",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"rollup": "^3.29.4",
"rollup-plugin-dts": "^6.0.2",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-polyfill-node": "^0.12.0",
"semantic-release": "^21.1.1",
"ts-node": "^10.9.1"
},
Expand All @@ -97,6 +102,7 @@
}
},
"dependencies": {
"@rollup/plugin-node-resolve": "^15.2.2",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.0",
Expand All @@ -105,10 +111,14 @@
"env-cmd": "^10.1.0",
"https-proxy-agent": "^7.0.2",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^18.2.0",
"react-query": "^3.39.2",
"react-scripts": "5.0.1",
"typescript": "^4.9.5"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^18.2.0"
}
}
73 changes: 73 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* eslint-disable import/no-extraneous-dependencies */
// @ts-check

/* eslint-env node */
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import dts from 'rollup-plugin-dts';
import json from '@rollup/plugin-json';

/**
* Rollup configuration to build the main bundle.
* @type {import('rollup').RollupOptions}
*/
const mainConfig = {
input: 'src/index.ts',
output: [
{
file: 'dist/index.esm.js',
format: 'esm',
sourcemap: true,
},
{
file: 'dist/index.js',
format: 'cjs',
sourcemap: true,
},
{
file: 'dist/index.min.js',
format: 'umd',
name: 'DatePicker',
plugins: [terser()],
sourcemap: true,
globals: {
react: 'React',
},
},
],
external: ['react', 'react-dom'],
plugins: [
peerDepsExternal(),
nodeResolve(),
commonjs(),
json(),
typescript({
tsconfig: './tsconfig.build.json',
declaration: false,
}),
nodePolyfills(),
],
};

/**
* Rollup configuration to build the type declaration file.
* @type {import('rollup').RollupOptions}
*/
export const dtsConfig = {
input: 'src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [
dts({
tsconfig: './tsconfig.build.json',
compilerOptions: {
preserveSymlinks: false,
},
}),
],
};

export default [mainConfig, dtsConfig];
7 changes: 4 additions & 3 deletions src/components/Translator.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable react/jsx-no-useless-fragment */
import React, {
JSX,
ReactNode,
ReactElement,
Children,
Expand Down Expand Up @@ -35,7 +37,6 @@ const Translation = ({
isError,
isLoading,
);
// eslint-disable-next-line react/jsx-no-useless-fragment
return <>{translatedText}</>;
};

Expand Down Expand Up @@ -79,14 +80,14 @@ const Translator = ({
to,
shouldFallback,
}: {
children: ReactNode;
children: ReactNode | React.ReactElement<any, any> | Element | JSX.Element;
from?: language;
to?: language;
shouldFallback?: boolean;
}) => (
<QueryClientProvider client={queryClient}>
<LanguageProvider>
{recursivelyTranslate(children, from, to, shouldFallback)}
{recursivelyTranslate(<>{children}</>, from, to, shouldFallback)}
</LanguageProvider>
</QueryClientProvider>
);
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
},
"exclude": ["**/*.test.*"],
"include": ["./src/**/*"]
}
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"compilerOptions": {
"jsx": "react-jsx",
"strict": true,
"esModuleInterop": true
"esModuleInterop": true,
"target": "es5",
"module": "esnext",
"moduleResolution": "node",
},
"include": [
"*.eslintrc.js",
Expand Down

0 comments on commit 878d2cd

Please sign in to comment.