diff options
| author | Shinigami <[email protected]> | 2023-07-18 13:25:38 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-18 13:25:38 +0200 |
| commit | 3df98a0cb330f0a67f4b1c37c168709aafc941d6 (patch) | |
| tree | ba2bc4687bce2b0b1254b7804769d04f71649919 | |
| parent | 5f947cbd4773f768a90243e54fd707c9769e8530 (diff) | |
| download | faker-3df98a0cb330f0a67f4b1c37c168709aafc941d6.tar.xz faker-3df98a0cb330f0a67f4b1c37c168709aafc941d6.zip | |
chore: remove legacy locale folder (#2263)
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | package.json | 5 | ||||
| -rw-r--r-- | scripts/bundle.ts | 16 | ||||
| -rw-r--r-- | test/locale-imports.spec.ts | 23 | ||||
| -rw-r--r-- | tsconfig.json | 2 |
5 files changed, 3 insertions, 44 deletions
@@ -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"] } |
