From a5adfef8645b739eb03886f9dc25c56606ab19ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Marie=20De=20Mey?= Date: Tue, 14 May 2024 16:05:54 +0300 Subject: [PATCH] umd panic --- package-lock.json | 35 +++++++++++++++++++++++++-- package.json | 5 ++-- rollup.config.js | 56 ++++++++++++++++++++++++++++++-------------- src/server/server.ts | 4 ++-- tsconfig.json | 1 + 5 files changed, 78 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 463be0d..8981832 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "omni18n", - "version": "1.0.8", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "omni18n", - "version": "1.0.8", + "version": "1.1.2", "license": "ISC", "dependencies": { "hjson": "^3.2.2" @@ -23,6 +23,7 @@ "prettier": "^3.2.5", "rollup": "^4.16.4", "rollup-plugin-dts": "^6.1.0", + "rollup-plugin-typescript": "^1.0.1", "rollup-plugin-typescript2": "^0.36.0", "ts-jest": "^29.1.2", "tslib": "^2.6.2", @@ -5344,6 +5345,21 @@ "typescript": "^4.5 || ^5.0" } }, + "node_modules/rollup-plugin-typescript": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz", + "integrity": "sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==", + "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-typescript.", + "dev": true, + "dependencies": { + "resolve": "^1.10.0", + "rollup-pluginutils": "^2.5.0" + }, + "peerDependencies": { + "tslib": "*", + "typescript": ">=2.1.0" + } + }, "node_modules/rollup-plugin-typescript2": { "version": "0.36.0", "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.36.0.tgz", @@ -5374,6 +5390,21 @@ "node": ">= 8.0.0" } }, + "node_modules/rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "dependencies": { + "estree-walker": "^0.6.1" + } + }, + "node_modules/rollup-pluginutils/node_modules/estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index c70d593..089ef37 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "omni18n", - "version": "1.1.2", + "version": "1.1.3", "description": "", "main": "dist/index.js", - "module": "dist/index.js", + "module": "dist/index.esm.js", "types": "dist/index.d.ts", "type": "module", "scripts": { @@ -40,6 +40,7 @@ "prettier": "^3.2.5", "rollup": "^4.16.4", "rollup-plugin-dts": "^6.1.0", + "rollup-plugin-typescript": "^1.0.1", "rollup-plugin-typescript2": "^0.36.0", "ts-jest": "^29.1.2", "tslib": "^2.6.2", diff --git a/rollup.config.js b/rollup.config.js index c291ca7..a8909fe 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,21 +2,43 @@ import resolve from '@rollup/plugin-node-resolve' import commonjs from '@rollup/plugin-commonjs' import typescript from 'rollup-plugin-typescript2' -export default { - input: './src/index.ts', - output: { - file: 'dist/index.js', - format: 'cjs' +export default [ + { + input: './src/index.ts', + output: { + file: 'dist/index.js', + sourcemap: true, + format: 'cjs' + }, + external: ['hjson'], + plugins: [ + resolve(), + commonjs(), + typescript({ + tsconfigOverride: { + include: ['./src'], + exclude: ['./node_modules'] + } + }) + ] }, - external: ['hjson'], - plugins: [ - resolve(), - commonjs(), - typescript({ - tsconfigOverride: { - include: ['./src'], - exclude: ['./node_modules'] - } - }) - ] -} + { + input: './src/index.ts', + output: { + file: 'dist/index.esm.js', + sourcemap: true, + format: 'esm' + }, + external: ['hjson'], + plugins: [ + resolve(), + commonjs(), + typescript({ + tsconfigOverride: { + include: ['./src'], + exclude: ['./node_modules'] + } + }) + ] + } +] diff --git a/src/server/server.ts b/src/server/server.ts index ed6d2b7..232edcf 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -24,7 +24,7 @@ export function localeTree(locale: Locale) { } // Remove duplicates while keeping the order -function removeDup(arr: string[]) { +function removeDuplicates(arr: string[]) { const done = new Set() return arr.filter((k) => !done.has(k) && done.add(k)) } @@ -40,7 +40,7 @@ export default class I18nServer { const [primary, ...fallbacks] = locales return this.db.list( - removeDup([...localeTree(primary), '', ...fallbacks.map(localeTree).flat()]), + removeDuplicates([...localeTree(primary), '', ...fallbacks.map(localeTree).flat()]), zone ) } diff --git a/tsconfig.json b/tsconfig.json index 726882d..a50dd04 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "moduleResolution": "Node", "target": "es2015", "module": "ESNext", "outDir": "./dist",