aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinigami <[email protected]>2023-07-18 13:25:38 +0200
committerGitHub <[email protected]>2023-07-18 13:25:38 +0200
commit3df98a0cb330f0a67f4b1c37c168709aafc941d6 (patch)
treeba2bc4687bce2b0b1254b7804769d04f71649919
parent5f947cbd4773f768a90243e54fd707c9769e8530 (diff)
downloadfaker-3df98a0cb330f0a67f4b1c37c168709aafc941d6.tar.xz
faker-3df98a0cb330f0a67f4b1c37c168709aafc941d6.zip
chore: remove legacy locale folder (#2263)
-rw-r--r--.gitignore1
-rw-r--r--package.json5
-rw-r--r--scripts/bundle.ts16
-rw-r--r--test/locale-imports.spec.ts23
-rw-r--r--tsconfig.json2
5 files changed, 3 insertions, 44 deletions
diff --git a/.gitignore b/.gitignore
index ab84a0a2..d50069ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,7 +80,6 @@ versions.json
/docs/api/typedoc.json
/docs/public/api-diff-index.json
/lib
-/locale
# Faker
TAGS
diff --git a/package.json b/package.json
index f8979949..5a84d7fe 100644
--- a/package.json
+++ b/package.json
@@ -53,11 +53,10 @@
},
"files": [
"CHANGELOG.md",
- "dist",
- "locale"
+ "dist"
],
"scripts": {
- "clean": "rimraf coverage .eslintcache dist docs/.vitepress/dist pnpm-lock.yaml node_modules",
+ "clean": "rimraf coverage .eslintcache dist docs/.vitepress/dist locale pnpm-lock.yaml node_modules",
"build:clean": "rimraf dist",
"build:code": "tsx ./scripts/bundle.ts",
"build:types": "tsc --project tsconfig.build.json",
diff --git a/scripts/bundle.ts b/scripts/bundle.ts
index b162a32e..8076f18d 100644
--- a/scripts/bundle.ts
+++ b/scripts/bundle.ts
@@ -1,27 +1,11 @@
import { buildSync } from 'esbuild';
import { globSync } from 'glob';
-import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { allLocales } from '../src';
console.log('Building dist for node (cjs)...');
-// Generate entry-points for cjs compatibility
-const localeDir = 'locale';
const target = ['ES2019', 'node14.17'];
-if (existsSync(localeDir)) {
- rmSync(localeDir, { recursive: true, force: true });
-}
-
-mkdirSync(localeDir);
-for (const locale of Object.keys(allLocales)) {
- writeFileSync(
- `${localeDir}/${locale}.js`,
- `module.exports = require('../dist/cjs/locale/${locale}');\n`,
- { encoding: 'utf8' }
- );
-}
-
buildSync({
entryPoints: globSync('./src/**/*.ts'),
// We can use the following entry points when esbuild supports cjs+splitting
diff --git a/test/locale-imports.spec.ts b/test/locale-imports.spec.ts
index 3cbe38aa..6882d537 100644
--- a/test/locale-imports.spec.ts
+++ b/test/locale-imports.spec.ts
@@ -62,27 +62,4 @@ describe.each(Object.keys(allLocales))('locale imports', (locale) => {
}
}
});
-
- describe('Internal tests to cover `src/locale/*.ts`', () => {
- it(`should be possible to directly require('../locale/${locale}')`, () => {
- // eslint-disable-next-line @typescript-eslint/no-var-requires
- const { faker } = require(`../locale/${locale}`);
-
- expect(faker).toBeDefined();
- expect(faker.string.alpha()).toBeTypeOf('string');
- expect(faker.definitions.metadata.title).toBe(
- allLocales[locale].metadata.title
- );
- });
-
- it(`should be possible to directly import('../src/locale/${locale}')`, async () => {
- const { faker } = await import(`../src/locale/${locale}`);
-
- expect(faker).toBeDefined();
- expect(faker.string.alpha()).toBeTypeOf('string');
- expect(faker.definitions.metadata.title).toBe(
- allLocales[locale].metadata.title
- );
- });
- });
});
diff --git a/tsconfig.json b/tsconfig.json
index 3a2b814f..c1dcb1dd 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -17,5 +17,5 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
},
- "exclude": ["node_modules", "dist", "locale"]
+ "exclude": ["node_modules", "dist"]
}