Skip to content

Commit

Permalink
chore: remove legacy locale folder (#2263)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Jul 18, 2023
1 parent 5f947cb commit 3df98a0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 44 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ versions.json
/docs/api/typedoc.json
/docs/public/api-diff-index.json
/lib
/locale

# Faker
TAGS
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 0 additions & 16 deletions scripts/bundle.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 0 additions & 23 deletions test/locale-imports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
});
});
});
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true
},
"exclude": ["node_modules", "dist", "locale"]
"exclude": ["node_modules", "dist"]
}

0 comments on commit 3df98a0

Please sign in to comment.