@fictjs/babel-preset 0.0.2
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 +17 -0
- package/dist/index.cjs +55 -0
- package/dist/index.d.cts +64 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +30 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @fictjs/babel-preset
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Babel preset for Fict - includes TypeScript, JSX, and Fict compiler
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -D @fictjs/babel-preset
|
|
13
|
+
# or
|
|
14
|
+
yarn add -D @fictjs/babel-preset
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
You can visit [Fict](https://github.com/fictjs/fict) for more documentation.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createFictPlugin: () => import_compiler2.createFictPlugin,
|
|
24
|
+
default: () => fictPreset
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_compiler = require("@fictjs/compiler");
|
|
28
|
+
var import_compiler2 = require("@fictjs/compiler");
|
|
29
|
+
function fictPreset(api, options = {}) {
|
|
30
|
+
api.assertVersion(7);
|
|
31
|
+
const { typescript = true, typescriptOptions = {}, ...compilerOptions } = options;
|
|
32
|
+
const { isTSX = true, allExtensions = true, allowNamespaces = true } = typescriptOptions;
|
|
33
|
+
const presets = [];
|
|
34
|
+
const plugins = [];
|
|
35
|
+
if (typescript) {
|
|
36
|
+
presets.push([
|
|
37
|
+
"@babel/preset-typescript",
|
|
38
|
+
{
|
|
39
|
+
isTSX,
|
|
40
|
+
allExtensions,
|
|
41
|
+
allowNamespaces
|
|
42
|
+
}
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
plugins.push(["@babel/plugin-syntax-jsx", {}]);
|
|
46
|
+
plugins.push([import_compiler.createFictPlugin, compilerOptions]);
|
|
47
|
+
return {
|
|
48
|
+
presets,
|
|
49
|
+
plugins
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
createFictPlugin
|
|
55
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ConfigAPI, TransformOptions } from '@babel/core';
|
|
2
|
+
import { FictCompilerOptions } from '@fictjs/compiler';
|
|
3
|
+
export { FictCompilerOptions, createFictPlugin } from '@fictjs/compiler';
|
|
4
|
+
|
|
5
|
+
interface FictPresetOptions extends FictCompilerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Enable TypeScript support.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
typescript?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* TypeScript preset options.
|
|
13
|
+
* Only used when typescript is true.
|
|
14
|
+
*/
|
|
15
|
+
typescriptOptions?: {
|
|
16
|
+
/**
|
|
17
|
+
* Enable TSX parsing.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
isTSX?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Parse all files as TSX.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
allExtensions?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Allow namespaces.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
allowNamespaces?: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Babel preset for Fict.
|
|
35
|
+
*
|
|
36
|
+
* Includes:
|
|
37
|
+
* - @babel/preset-typescript (optional, enabled by default)
|
|
38
|
+
* - @babel/plugin-syntax-jsx
|
|
39
|
+
* - @fictjs/compiler
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* // babel.config.js
|
|
44
|
+
* module.exports = {
|
|
45
|
+
* presets: ['@fictjs/babel-preset']
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
* // With options
|
|
52
|
+
* module.exports = {
|
|
53
|
+
* presets: [
|
|
54
|
+
* ['@fictjs/babel-preset', {
|
|
55
|
+
* dev: true,
|
|
56
|
+
* typescript: true,
|
|
57
|
+
* }]
|
|
58
|
+
* ]
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function fictPreset(api: ConfigAPI, options?: FictPresetOptions): TransformOptions;
|
|
63
|
+
|
|
64
|
+
export { type FictPresetOptions, fictPreset as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ConfigAPI, TransformOptions } from '@babel/core';
|
|
2
|
+
import { FictCompilerOptions } from '@fictjs/compiler';
|
|
3
|
+
export { FictCompilerOptions, createFictPlugin } from '@fictjs/compiler';
|
|
4
|
+
|
|
5
|
+
interface FictPresetOptions extends FictCompilerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Enable TypeScript support.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
typescript?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* TypeScript preset options.
|
|
13
|
+
* Only used when typescript is true.
|
|
14
|
+
*/
|
|
15
|
+
typescriptOptions?: {
|
|
16
|
+
/**
|
|
17
|
+
* Enable TSX parsing.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
isTSX?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Parse all files as TSX.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
allExtensions?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Allow namespaces.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
allowNamespaces?: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Babel preset for Fict.
|
|
35
|
+
*
|
|
36
|
+
* Includes:
|
|
37
|
+
* - @babel/preset-typescript (optional, enabled by default)
|
|
38
|
+
* - @babel/plugin-syntax-jsx
|
|
39
|
+
* - @fictjs/compiler
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* // babel.config.js
|
|
44
|
+
* module.exports = {
|
|
45
|
+
* presets: ['@fictjs/babel-preset']
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
* // With options
|
|
52
|
+
* module.exports = {
|
|
53
|
+
* presets: [
|
|
54
|
+
* ['@fictjs/babel-preset', {
|
|
55
|
+
* dev: true,
|
|
56
|
+
* typescript: true,
|
|
57
|
+
* }]
|
|
58
|
+
* ]
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function fictPreset(api: ConfigAPI, options?: FictPresetOptions): TransformOptions;
|
|
63
|
+
|
|
64
|
+
export { type FictPresetOptions, fictPreset as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createFictPlugin } from "@fictjs/compiler";
|
|
3
|
+
import { createFictPlugin as createFictPlugin2 } from "@fictjs/compiler";
|
|
4
|
+
function fictPreset(api, options = {}) {
|
|
5
|
+
api.assertVersion(7);
|
|
6
|
+
const { typescript = true, typescriptOptions = {}, ...compilerOptions } = options;
|
|
7
|
+
const { isTSX = true, allExtensions = true, allowNamespaces = true } = typescriptOptions;
|
|
8
|
+
const presets = [];
|
|
9
|
+
const plugins = [];
|
|
10
|
+
if (typescript) {
|
|
11
|
+
presets.push([
|
|
12
|
+
"@babel/preset-typescript",
|
|
13
|
+
{
|
|
14
|
+
isTSX,
|
|
15
|
+
allExtensions,
|
|
16
|
+
allowNamespaces
|
|
17
|
+
}
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
plugins.push(["@babel/plugin-syntax-jsx", {}]);
|
|
21
|
+
plugins.push([createFictPlugin, compilerOptions]);
|
|
22
|
+
return {
|
|
23
|
+
presets,
|
|
24
|
+
plugins
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
createFictPlugin2 as createFictPlugin,
|
|
29
|
+
fictPreset as default
|
|
30
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fictjs/babel-preset",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Babel preset for Fict - includes TypeScript, JSX, and Fict compiler",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup",
|
|
24
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch",
|
|
25
|
+
"lint": "eslint src",
|
|
26
|
+
"typecheck": "echo 'Types checked via dependencies'",
|
|
27
|
+
"clean": "rm -rf dist"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@babel/core": ">=7.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@babel/plugin-syntax-jsx": "^7.27.1",
|
|
34
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
35
|
+
"@fictjs/compiler": "workspace:*"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@babel/core": "^7.26.0",
|
|
39
|
+
"@types/babel__core": "^7.20.5",
|
|
40
|
+
"tsup": "^8.5.1"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"babel-preset",
|
|
44
|
+
"fict",
|
|
45
|
+
"jsx",
|
|
46
|
+
"typescript",
|
|
47
|
+
"reactive"
|
|
48
|
+
],
|
|
49
|
+
"author": "Michael Lin",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/fictjs/fict.git",
|
|
54
|
+
"directory": "packages/babel-preset"
|
|
55
|
+
}
|
|
56
|
+
}
|