@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 +9 -0
- package/bin/babel-config-default-extensions.js +3 -0
- package/configs/cjs.js +11 -0
- package/configs/esm.js +18 -0
- package/configs/index.js +3 -0
- package/configs/resolve-tsconfig-paths.js +40 -0
- package/constants/DEFAULT_EXTENSIONS.js +3 -0
- package/constants/index.js +1 -0
- package/eslint.config.mjs +5 -0
- package/ignores/ignore-test-files.js +7 -0
- package/ignores/index.js +1 -0
- package/index.js +5 -0
- package/package.json +44 -0
- package/presets/index.js +1 -0
- package/presets/package.js +29 -0
- package/prettier.config.mjs +10 -0
- package/tsconfig.json +10 -0
package/README.md
ADDED
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
|
+
}
|
package/configs/index.js
ADDED
|
@@ -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 @@
|
|
|
1
|
+
export { default as DEFAULT_EXTENSIONS } from './DEFAULT_EXTENSIONS.js';
|
package/ignores/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as testFiles } from './ignore-test-files.js';
|
package/index.js
ADDED
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
|
+
}
|
package/presets/index.js
ADDED
|
@@ -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
|
+
}
|