diff --git a/.gitignore b/.gitignore index ab84a0a2ac1..d50069baccf 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 f89799491ca..5a84d7fe69d 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 b162a32ecfb..8076f18da7e 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 3cbe38aabce..6882d5379c8 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 3a2b814f2c5..c1dcb1ddfb7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,5 +17,5 @@ "allowSyntheticDefaultImports": true, "resolveJsonModule": true }, - "exclude": ["node_modules", "dist", "locale"] + "exclude": ["node_modules", "dist"] }