@zetavg/babel-config 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Babel Config
2
+
3
+ Shared Babel configurations.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ yarn add @zetavg/babel-config --dev
9
+ ```
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import DEFAULT_EXTENSIONS from '../constants/DEFAULT_EXTENSIONS.js';
3
+ process.stdout.write(DEFAULT_EXTENSIONS.join(','));
package/configs/cjs.js ADDED
@@ -0,0 +1,11 @@
1
+ import commonjsPlugin from '@babel/plugin-transform-modules-commonjs';
2
+
3
+ /**
4
+ * Babel configuration for CommonJS output.
5
+ * @type {import('@babel/core').ConfigFunction}
6
+ */
7
+ export default function () {
8
+ return {
9
+ plugins: [commonjsPlugin],
10
+ };
11
+ }
package/configs/esm.js ADDED
@@ -0,0 +1,18 @@
1
+ import moduleExtensionResolverPlugin from 'babel-plugin-module-extension-resolver';
2
+
3
+ /**
4
+ * Babel configuration for ES Module output.
5
+ * @type {import('@babel/core').ConfigFunction}
6
+ */
7
+ export default function () {
8
+ return {
9
+ plugins: [
10
+ [
11
+ moduleExtensionResolverPlugin,
12
+ {
13
+ dstExtension: '.mjs',
14
+ },
15
+ ],
16
+ ],
17
+ };
18
+ }
@@ -0,0 +1,3 @@
1
+ export { default as cjs } from './cjs.js';
2
+ export { default as esm } from './esm.js';
3
+ export { default as resolveTsconfigPaths } from './resolve-tsconfig-paths.js';
@@ -0,0 +1,40 @@
1
+ import moduleResolverPlugin from 'babel-plugin-module-resolver';
2
+ import tsconfigPaths from 'tsconfig-paths';
3
+
4
+ import * as constants from '../constants/index.js';
5
+
6
+ /**
7
+ * Babel configuration that resolves TypeScript paths based on the `tsconfig.json` file.
8
+ * @type {import('@babel/core').ConfigFunction}
9
+ */
10
+ export default function () {
11
+ const tsconfigPathsConfigLoadResult = tsconfigPaths.loadConfig();
12
+
13
+ return {
14
+ plugins: [
15
+ [
16
+ moduleResolverPlugin,
17
+ {
18
+ extensions: constants.DEFAULT_EXTENSIONS,
19
+ cwd: tsconfigPathsConfigLoadResult.baseUrl,
20
+ alias: {
21
+ ...Object.fromEntries(
22
+ Object.entries(tsconfigPathsConfigLoadResult.paths).map(
23
+ ([k, v]) => {
24
+ const key = k.replace(/\/\*$/, '');
25
+ let value = v[0].replace(/\/\*$/, '');
26
+
27
+ if (!value.startsWith('./')) {
28
+ value = `./${value}`;
29
+ }
30
+
31
+ return [key, value];
32
+ },
33
+ ),
34
+ ),
35
+ },
36
+ },
37
+ ],
38
+ ],
39
+ };
40
+ }
@@ -0,0 +1,3 @@
1
+ import babel from '@babel/core';
2
+
3
+ export default [...babel.DEFAULT_EXTENSIONS, '.ts', '.mts', '.cts', '.tsx'];
@@ -0,0 +1 @@
1
+ export { default as DEFAULT_EXTENSIONS } from './DEFAULT_EXTENSIONS.js';
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from 'eslint/config';
2
+
3
+ import config from '@zetavg/eslint-config';
4
+
5
+ export default defineConfig([config]);
@@ -0,0 +1,7 @@
1
+ import * as constants from '../constants/index.js';
2
+
3
+ export default [
4
+ // https://github.com/babel/babel/issues/12008
5
+ ...constants.DEFAULT_EXTENSIONS.map((ext) => `**/*.test${ext}`),
6
+ '**/__tests__/**',
7
+ ];
@@ -0,0 +1 @@
1
+ export { default as testFiles } from './ignore-test-files.js';
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import * as constants from './constants/index.js';
2
+ import * as ignores from './ignores/index.js';
3
+ import * as presets from './presets/index.js';
4
+
5
+ export { constants, ignores, presets };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@zetavg/babel-config",
3
+ "type": "module",
4
+ "main": "index.js",
5
+ "bin": {
6
+ "babel-config-default-extensions": "bin/babel-config-default-extensions.js"
7
+ },
8
+ "scripts": {
9
+ "lint": "eslint .",
10
+ "build:types": "tsc",
11
+ "build": "yarn build:types",
12
+ "watch:types": "yarn build:types --watch --preserveWatchOutput",
13
+ "watch": "yarn watch:types",
14
+ "pack-package": "yarn pack",
15
+ "publish-packed-package": "npm publish package.tgz --access public",
16
+ "clean": "rm -rf package.tgz"
17
+ },
18
+ "peerDependencies": {
19
+ "@babel/cli": "^7",
20
+ "@babel/core": "^7"
21
+ },
22
+ "peerDependenciesMeta": {
23
+ "@babel/cli": {
24
+ "optional": true
25
+ }
26
+ },
27
+ "dependencies": {
28
+ "@babel/plugin-transform-modules-commonjs": "^7",
29
+ "@babel/preset-env": "^7",
30
+ "@babel/preset-typescript": "^7",
31
+ "babel-plugin-module-extension-resolver": "^1",
32
+ "babel-plugin-module-resolver": "^5",
33
+ "tsconfig-paths": "^4"
34
+ },
35
+ "devDependencies": {
36
+ "@zetavg/eslint-config": "workspace:^",
37
+ "@zetavg/prettier-config": "workspace:^",
38
+ "@zetavg/tsconfig": "workspace:^",
39
+ "eslint": "^9",
40
+ "prettier": "^3",
41
+ "typescript": "~5.8"
42
+ },
43
+ "version": "0.0.1"
44
+ }
@@ -0,0 +1 @@
1
+ export { default as package } from './package.js';
@@ -0,0 +1,29 @@
1
+ import typescriptPreset from '@babel/preset-typescript';
2
+
3
+ import * as configs from '../configs/index.js';
4
+
5
+ /**
6
+ * Babel configuration for dual module package builds.
7
+ * @type {import('@babel/core').ConfigFunction}
8
+ */
9
+ export default function (api) {
10
+ const env = api.env();
11
+
12
+ return {
13
+ presets: [
14
+ ...(() => {
15
+ switch (env) {
16
+ case 'cjs':
17
+ return [configs.cjs];
18
+ case 'esm':
19
+ return [configs.esm];
20
+ default:
21
+ return [];
22
+ }
23
+ })(),
24
+ configs.resolveTsconfigPaths,
25
+ typescriptPreset,
26
+ ],
27
+ sourceMaps: true,
28
+ };
29
+ }
@@ -0,0 +1,10 @@
1
+ import defaultConfig from '@zetavg/prettier-config';
2
+
3
+ /**
4
+ * @type {import("prettier").Config}
5
+ */
6
+ const config = {
7
+ ...defaultConfig,
8
+ };
9
+
10
+ export default config;
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@zetavg/tsconfig",
3
+ "include": ["**/*.js"],
4
+ "compilerOptions": {
5
+ "allowJs": true,
6
+ "declaration": true,
7
+ "outDir": "dist/types",
8
+ "emitDeclarationOnly": true
9
+ }
10
+ }