@danielx/civet 0.7.20 → 0.7.22

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.
@@ -0,0 +1,49 @@
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
+ // source/babel-plugin.civet
21
+ var babel_plugin_exports = {};
22
+ __export(babel_plugin_exports, {
23
+ default: () => babel_plugin_default
24
+ });
25
+ module.exports = __toCommonJS(babel_plugin_exports);
26
+ var import_main = require("./main.js");
27
+ function babel_plugin_default(api, civetOptions) {
28
+ return {
29
+ parserOverride(code, opts, parse) {
30
+ let src;
31
+ if (opts.sourceFileName.endsWith(".civet")) {
32
+ const config = {
33
+ ...civetOptions,
34
+ filename: opts.sourceFileName,
35
+ sourceMap: false,
36
+ sync: true
37
+ // parserOverride API is synchronous
38
+ };
39
+ config.inlineMap ??= true;
40
+ config.js = true;
41
+ src = (0, import_main.compile)(code, config);
42
+ } else {
43
+ src = code;
44
+ }
45
+ const ast = parse(src, opts);
46
+ return ast;
47
+ }
48
+ };
49
+ }
@@ -1,41 +1,28 @@
1
- // Babel plugin for compiling .civet files
2
-
3
- /* Example babel.config.json:
4
-
5
- {
6
- "plugins": [
7
- [
8
- "@danielx/civet/babel-plugin"
9
- ]
10
- ],
11
- "sourceMaps": "inline"
12
- }
13
-
14
- */
15
-
16
- import { compile } from "./main.mjs"
17
-
18
- export default function (api, civetOptions) {
1
+ // source/babel-plugin.civet
2
+ import { compile } from "./main.mjs";
3
+ function babel_plugin_default(api, civetOptions) {
19
4
  return {
20
5
  parserOverride(code, opts, parse) {
21
- let src
6
+ let src;
22
7
  if (opts.sourceFileName.endsWith(".civet")) {
23
8
  const config = {
24
9
  ...civetOptions,
25
10
  filename: opts.sourceFileName,
26
11
  sourceMap: false,
27
- sync: true, // parserOverride API is synchronous
28
- }
29
-
30
- config.inlineMap ??= true
31
- config.js = true
32
- src = compile(code, config)
12
+ sync: true
13
+ // parserOverride API is synchronous
14
+ };
15
+ config.inlineMap ??= true;
16
+ config.js = true;
17
+ src = compile(code, config);
33
18
  } else {
34
- src = code
19
+ src = code;
35
20
  }
36
-
37
- const ast = parse(src, opts)
38
- return ast
21
+ const ast = parse(src, opts);
22
+ return ast;
39
23
  }
40
- }
24
+ };
41
25
  }
26
+ export {
27
+ babel_plugin_default as default
28
+ };