@redmix/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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/__tests__/api.test.d.ts +2 -0
  4. package/dist/__tests__/api.test.d.ts.map +1 -0
  5. package/dist/__tests__/common.test.d.ts +2 -0
  6. package/dist/__tests__/common.test.d.ts.map +1 -0
  7. package/dist/__tests__/prebuildApiFile.test.d.ts +6 -0
  8. package/dist/__tests__/prebuildApiFile.test.d.ts.map +1 -0
  9. package/dist/__tests__/tsconfigParsing.test.d.ts +2 -0
  10. package/dist/__tests__/tsconfigParsing.test.d.ts.map +1 -0
  11. package/dist/api.d.ts +37 -0
  12. package/dist/api.d.ts.map +1 -0
  13. package/dist/api.js +258 -0
  14. package/dist/common.d.ts +50 -0
  15. package/dist/common.d.ts.map +1 -0
  16. package/dist/common.js +145 -0
  17. package/dist/index.d.ts +5 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +70 -0
  20. package/dist/plugins/__tests__/babel-plugin-redwood-cell.test.d.ts +2 -0
  21. package/dist/plugins/__tests__/babel-plugin-redwood-cell.test.d.ts.map +1 -0
  22. package/dist/plugins/__tests__/babel-plugin-redwood-context-wrapping.test.d.ts +2 -0
  23. package/dist/plugins/__tests__/babel-plugin-redwood-context-wrapping.test.d.ts.map +1 -0
  24. package/dist/plugins/__tests__/babel-plugin-redwood-directory-named-imports.test.d.ts +2 -0
  25. package/dist/plugins/__tests__/babel-plugin-redwood-directory-named-imports.test.d.ts.map +1 -0
  26. package/dist/plugins/__tests__/babel-plugin-redwood-graphql-options-extract.test.d.ts +2 -0
  27. package/dist/plugins/__tests__/babel-plugin-redwood-graphql-options-extract.test.d.ts.map +1 -0
  28. package/dist/plugins/__tests__/babel-plugin-redwood-import-dir.test.d.ts +2 -0
  29. package/dist/plugins/__tests__/babel-plugin-redwood-import-dir.test.d.ts.map +1 -0
  30. package/dist/plugins/__tests__/babel-plugin-redwood-mock-cell-data.test.d.ts +2 -0
  31. package/dist/plugins/__tests__/babel-plugin-redwood-mock-cell-data.test.d.ts.map +1 -0
  32. package/dist/plugins/__tests__/babel-plugin-redwood-otel-wrapping.test.d.ts +2 -0
  33. package/dist/plugins/__tests__/babel-plugin-redwood-otel-wrapping.test.d.ts.map +1 -0
  34. package/dist/plugins/__tests__/babel-plugin-redwood-remove-dev-fatal-error-page.test.d.ts +2 -0
  35. package/dist/plugins/__tests__/babel-plugin-redwood-remove-dev-fatal-error-page.test.d.ts.map +1 -0
  36. package/dist/plugins/__tests__/babel-plugin-redwood-routes-auto-loader.test.d.ts +2 -0
  37. package/dist/plugins/__tests__/babel-plugin-redwood-routes-auto-loader.test.d.ts.map +1 -0
  38. package/dist/plugins/__tests__/babel-plugin-redwood-src-alias.test.d.ts +2 -0
  39. package/dist/plugins/__tests__/babel-plugin-redwood-src-alias.test.d.ts.map +1 -0
  40. package/dist/plugins/babel-plugin-redwood-cell.d.ts +5 -0
  41. package/dist/plugins/babel-plugin-redwood-cell.d.ts.map +1 -0
  42. package/dist/plugins/babel-plugin-redwood-cell.js +115 -0
  43. package/dist/plugins/babel-plugin-redwood-context-wrapping.d.ts +7 -0
  44. package/dist/plugins/babel-plugin-redwood-context-wrapping.d.ts.map +1 -0
  45. package/dist/plugins/babel-plugin-redwood-context-wrapping.js +134 -0
  46. package/dist/plugins/babel-plugin-redwood-directory-named-import.d.ts +5 -0
  47. package/dist/plugins/babel-plugin-redwood-directory-named-import.d.ts.map +1 -0
  48. package/dist/plugins/babel-plugin-redwood-directory-named-import.js +94 -0
  49. package/dist/plugins/babel-plugin-redwood-graphql-options-extract.d.ts +5 -0
  50. package/dist/plugins/babel-plugin-redwood-graphql-options-extract.d.ts.map +1 -0
  51. package/dist/plugins/babel-plugin-redwood-graphql-options-extract.js +88 -0
  52. package/dist/plugins/babel-plugin-redwood-import-dir.d.ts +23 -0
  53. package/dist/plugins/babel-plugin-redwood-import-dir.d.ts.map +1 -0
  54. package/dist/plugins/babel-plugin-redwood-import-dir.js +98 -0
  55. package/dist/plugins/babel-plugin-redwood-job-path-injector.d.ts +5 -0
  56. package/dist/plugins/babel-plugin-redwood-job-path-injector.d.ts.map +1 -0
  57. package/dist/plugins/babel-plugin-redwood-job-path-injector.js +118 -0
  58. package/dist/plugins/babel-plugin-redwood-mock-cell-data.d.ts +18 -0
  59. package/dist/plugins/babel-plugin-redwood-mock-cell-data.d.ts.map +1 -0
  60. package/dist/plugins/babel-plugin-redwood-mock-cell-data.js +244 -0
  61. package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts +5 -0
  62. package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts.map +1 -0
  63. package/dist/plugins/babel-plugin-redwood-otel-wrapping.js +329 -0
  64. package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.d.ts +5 -0
  65. package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.d.ts.map +1 -0
  66. package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.js +41 -0
  67. package/dist/plugins/babel-plugin-redwood-routes-auto-loader.d.ts +23 -0
  68. package/dist/plugins/babel-plugin-redwood-routes-auto-loader.d.ts.map +1 -0
  69. package/dist/plugins/babel-plugin-redwood-routes-auto-loader.js +182 -0
  70. package/dist/plugins/babel-plugin-redwood-src-alias.d.ts +8 -0
  71. package/dist/plugins/babel-plugin-redwood-src-alias.d.ts.map +1 -0
  72. package/dist/plugins/babel-plugin-redwood-src-alias.js +72 -0
  73. package/dist/web.d.ts +21 -0
  74. package/dist/web.d.ts.map +1 -0
  75. package/dist/web.js +239 -0
  76. package/package.json +60 -0
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-graphql-options-extract.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-graphql-options-extract.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-graphql-options-extract.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-import-dir.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-import-dir.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-import-dir.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-mock-cell-data.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-mock-cell-data.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-mock-cell-data.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-otel-wrapping.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-otel-wrapping.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-otel-wrapping.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-remove-dev-fatal-error-page.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-remove-dev-fatal-error-page.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-remove-dev-fatal-error-page.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-routes-auto-loader.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-routes-auto-loader.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-routes-auto-loader.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=babel-plugin-redwood-src-alias.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-src-alias.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/babel-plugin-redwood-src-alias.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export default function ({ types: t }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-cell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AA+BnD,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CAgHzE"}
@@ -0,0 +1,115 @@
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
+ var babel_plugin_redwood_cell_exports = {};
20
+ __export(babel_plugin_redwood_cell_exports, {
21
+ default: () => babel_plugin_redwood_cell_default
22
+ });
23
+ module.exports = __toCommonJS(babel_plugin_redwood_cell_exports);
24
+ var import_path = require("path");
25
+ const EXPECTED_EXPORTS_FROM_CELL = [
26
+ "beforeQuery",
27
+ "QUERY",
28
+ "data",
29
+ "isEmpty",
30
+ "afterQuery",
31
+ "Loading",
32
+ "Success",
33
+ "Failure",
34
+ "Empty"
35
+ ];
36
+ function babel_plugin_redwood_cell_default({ types: t }) {
37
+ let exportNames = [];
38
+ let hasDefaultExport = false;
39
+ return {
40
+ name: "babel-plugin-redwood-cell",
41
+ visitor: {
42
+ ExportDefaultDeclaration() {
43
+ hasDefaultExport = true;
44
+ },
45
+ ExportNamedDeclaration(path) {
46
+ const declaration = path.node.declaration;
47
+ if (!declaration) {
48
+ return;
49
+ }
50
+ let name;
51
+ if (declaration.type === "VariableDeclaration") {
52
+ const id = declaration.declarations[0].id;
53
+ name = id.name;
54
+ }
55
+ if (declaration.type === "FunctionDeclaration") {
56
+ name = declaration?.id?.name;
57
+ }
58
+ if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
59
+ exportNames.push(name);
60
+ }
61
+ },
62
+ Program: {
63
+ enter() {
64
+ exportNames = [];
65
+ hasDefaultExport = false;
66
+ },
67
+ exit(path) {
68
+ const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
69
+ if (hasDefaultExport || !hasQueryOrDataExport) {
70
+ return;
71
+ }
72
+ const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
73
+ const importFrom = exportNames.includes("data") ? "@redmix/web/dist/components/cell/createServerCell" : "@redmix/web";
74
+ path.node.body.unshift(
75
+ t.importDeclaration(
76
+ [
77
+ t.importSpecifier(
78
+ t.identifier(createCellHookName),
79
+ t.identifier(createCellHookName)
80
+ )
81
+ ],
82
+ t.stringLiteral(importFrom)
83
+ )
84
+ );
85
+ path.node.body.push(
86
+ t.exportDefaultDeclaration(
87
+ t.callExpression(t.identifier(createCellHookName), [
88
+ t.objectExpression([
89
+ ...exportNames.map(
90
+ (name) => t.objectProperty(
91
+ t.identifier(name),
92
+ t.identifier(name),
93
+ false,
94
+ true
95
+ )
96
+ ),
97
+ // Add the `displayName` property so we can name the Cell
98
+ // after the filename.
99
+ t.objectProperty(
100
+ t.identifier("displayName"),
101
+ t.stringLiteral(
102
+ (0, import_path.parse)(this.file.opts.filename).name
103
+ ),
104
+ false,
105
+ true
106
+ )
107
+ ])
108
+ ])
109
+ )
110
+ );
111
+ }
112
+ }
113
+ }
114
+ };
115
+ }
@@ -0,0 +1,7 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export default function ({ types: t }: {
3
+ types: typeof types;
4
+ }, { projectIsEsm }?: {
5
+ projectIsEsm?: boolean;
6
+ }): PluginObj;
7
+ //# sourceMappingURL=babel-plugin-redwood-context-wrapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-context-wrapping.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-context-wrapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAkEnD,MAAM,CAAC,OAAO,WACZ,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EACrC,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,SAAS,CA+DX"}
@@ -0,0 +1,134 @@
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
+ var babel_plugin_redwood_context_wrapping_exports = {};
20
+ __export(babel_plugin_redwood_context_wrapping_exports, {
21
+ default: () => babel_plugin_redwood_context_wrapping_default
22
+ });
23
+ module.exports = __toCommonJS(babel_plugin_redwood_context_wrapping_exports);
24
+ function generateWrappedHandler(t, isAsync) {
25
+ const contextStoreVariableDeclaration = t.variableDeclaration("const", [
26
+ t.variableDeclarator(
27
+ t.identifier("__rw_contextStore"),
28
+ t.callExpression(
29
+ t.memberExpression(
30
+ t.callExpression(t.identifier("__rw_getAsyncStoreInstance"), []),
31
+ t.identifier("getStore")
32
+ ),
33
+ []
34
+ )
35
+ )
36
+ ]);
37
+ t.addComment(
38
+ contextStoreVariableDeclaration,
39
+ "leading",
40
+ " The store will be undefined if no context isolation has been performed yet",
41
+ true
42
+ );
43
+ return t.arrowFunctionExpression(
44
+ [t.identifier("__rw_event"), t.identifier("__rw__context")],
45
+ t.blockStatement([
46
+ contextStoreVariableDeclaration,
47
+ t.ifStatement(
48
+ t.binaryExpression(
49
+ "===",
50
+ t.identifier("__rw_contextStore"),
51
+ t.identifier("undefined")
52
+ ),
53
+ t.blockStatement([
54
+ t.returnStatement(
55
+ t.callExpression(
56
+ t.memberExpression(
57
+ t.callExpression(
58
+ t.identifier("__rw_getAsyncStoreInstance"),
59
+ []
60
+ ),
61
+ t.identifier("run")
62
+ ),
63
+ [
64
+ t.newExpression(t.identifier("Map"), []),
65
+ t.identifier("__rw_handler"),
66
+ t.identifier("__rw_event"),
67
+ t.identifier("__rw__context")
68
+ ]
69
+ )
70
+ )
71
+ ])
72
+ ),
73
+ t.returnStatement(
74
+ t.callExpression(t.identifier("__rw_handler"), [
75
+ t.identifier("__rw_event"),
76
+ t.identifier("__rw__context")
77
+ ])
78
+ )
79
+ ]),
80
+ isAsync
81
+ );
82
+ }
83
+ function babel_plugin_redwood_context_wrapping_default({ types: t }, { projectIsEsm = false } = {}) {
84
+ return {
85
+ name: "babel-plugin-redwood-context-wrapping",
86
+ visitor: {
87
+ ExportNamedDeclaration(path, _state) {
88
+ const declaration = path.node.declaration;
89
+ if (!t.isVariableDeclaration(declaration)) {
90
+ return;
91
+ }
92
+ const identifier = declaration.declarations[0].id;
93
+ if (!t.isIdentifier(identifier)) {
94
+ return;
95
+ }
96
+ if (identifier.name !== "handler") {
97
+ return;
98
+ }
99
+ const parentNode = path.parentPath.node;
100
+ if (!t.isProgram(parentNode)) {
101
+ return;
102
+ }
103
+ path.insertBefore(
104
+ // import { getAsyncStoreInstance as __rw_getAsyncStoreInstance } from '@redmix/context/dist/store'
105
+ t.importDeclaration(
106
+ [
107
+ t.importSpecifier(
108
+ t.identifier("__rw_getAsyncStoreInstance"),
109
+ t.identifier("getAsyncStoreInstance")
110
+ )
111
+ ],
112
+ t.stringLiteral(
113
+ projectIsEsm ? "@redmix/context/dist/store.js" : "@redmix/context/dist/store"
114
+ )
115
+ )
116
+ );
117
+ path.insertBefore(
118
+ t.variableDeclaration("const", [
119
+ t.variableDeclarator(
120
+ t.identifier("__rw_handler"),
121
+ declaration.declarations[0].init
122
+ )
123
+ ])
124
+ );
125
+ let isAsync = false;
126
+ const originalInit = declaration.declarations[0].init;
127
+ if (t.isFunction(originalInit)) {
128
+ isAsync = originalInit.async;
129
+ }
130
+ declaration.declarations[0].init = generateWrappedHandler(t, isAsync);
131
+ }
132
+ }
133
+ };
134
+ }
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export default function ({ types: t }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-directory-named-import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-directory-named-import.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-directory-named-import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAuBnD,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CA2DzE"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var babel_plugin_redwood_directory_named_import_exports = {};
30
+ __export(babel_plugin_redwood_directory_named_import_exports, {
31
+ default: () => babel_plugin_redwood_directory_named_import_default
32
+ });
33
+ module.exports = __toCommonJS(babel_plugin_redwood_directory_named_import_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_project_config = require("@redmix/project-config");
36
+ const getNewPath = (value, filename) => {
37
+ const dirname = import_path.default.dirname(value);
38
+ const basename = import_path.default.basename(value);
39
+ const indexImportPath = [dirname, basename, "index"].join("/");
40
+ if ((0, import_project_config.resolveFile)(import_path.default.resolve(import_path.default.dirname(filename), indexImportPath))) {
41
+ return indexImportPath;
42
+ } else {
43
+ const dirnameImportPath = [dirname, basename, basename].join("/");
44
+ if ((0, import_project_config.resolveFile)(import_path.default.resolve(import_path.default.dirname(filename), dirnameImportPath))) {
45
+ return dirnameImportPath;
46
+ }
47
+ }
48
+ return null;
49
+ };
50
+ function babel_plugin_redwood_directory_named_import_default({ types: t }) {
51
+ return {
52
+ visitor: {
53
+ ImportDeclaration(p, state) {
54
+ const { value } = p.node.source;
55
+ const { filename } = state.file.opts;
56
+ if (filename?.includes("/node_modules/")) {
57
+ return;
58
+ }
59
+ try {
60
+ require.resolve(value);
61
+ return;
62
+ } catch {
63
+ }
64
+ const newPath = getNewPath(value, filename);
65
+ if (!newPath) {
66
+ return;
67
+ }
68
+ const newSource = t.stringLiteral(newPath);
69
+ p.node.source = newSource;
70
+ },
71
+ ExportDeclaration(p, state) {
72
+ if (!p?.node?.source) {
73
+ return;
74
+ }
75
+ const { value } = p.node.source;
76
+ const { filename } = state.file.opts;
77
+ if (filename?.includes("/node_modules/")) {
78
+ return;
79
+ }
80
+ try {
81
+ require.resolve(value);
82
+ return;
83
+ } catch {
84
+ }
85
+ const newPath = getNewPath(value, filename);
86
+ if (!newPath) {
87
+ return;
88
+ }
89
+ const newSource = t.stringLiteral(newPath);
90
+ p.node.source = newSource;
91
+ }
92
+ }
93
+ };
94
+ }
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ export default function ({ types: t }: {
3
+ types: typeof types;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-graphql-options-extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-graphql-options-extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAc,KAAK,EAAE,MAAM,aAAa,CAAA;AAiCzE,MAAM,CAAC,OAAO,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,GAAG,SAAS,CAoEzE"}
@@ -0,0 +1,88 @@
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
+ var babel_plugin_redwood_graphql_options_extract_exports = {};
20
+ __export(babel_plugin_redwood_graphql_options_extract_exports, {
21
+ default: () => babel_plugin_redwood_graphql_options_extract_default
22
+ });
23
+ module.exports = __toCommonJS(babel_plugin_redwood_graphql_options_extract_exports);
24
+ const exportVariableName = "__rw_graphqlOptions";
25
+ function optionsConstNode(t, value, state) {
26
+ if (t.isIdentifier(value) || t.isObjectExpression(value) || t.isCallExpression(value) || t.isConditionalExpression(value)) {
27
+ return t.exportNamedDeclaration(
28
+ t.variableDeclaration("const", [
29
+ t.variableDeclarator(t.identifier(exportVariableName), value)
30
+ ])
31
+ );
32
+ } else {
33
+ throw new Error(
34
+ `Unable to parse graphql function options in '${state.file.opts.filename}'`
35
+ );
36
+ }
37
+ }
38
+ function babel_plugin_redwood_graphql_options_extract_default({ types: t }) {
39
+ return {
40
+ name: "babel-plugin-redwood-graphql-options-extract",
41
+ visitor: {
42
+ Program(path, state) {
43
+ const importNames = /* @__PURE__ */ new Set();
44
+ path.traverse({
45
+ ImportDeclaration(p) {
46
+ if (t.isStringLiteral(p.node.source, {
47
+ value: "@redmix/graphql-server"
48
+ })) {
49
+ for (const specifier of p.node.specifiers) {
50
+ if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported) && specifier.imported.name === "createGraphQLHandler") {
51
+ importNames.add(specifier.local.name);
52
+ }
53
+ }
54
+ }
55
+ }
56
+ });
57
+ const callExpressionPaths = [];
58
+ path.traverse({
59
+ CallExpression(p) {
60
+ if (t.isIdentifier(p.node.callee) && importNames.has(p.node.callee.name)) {
61
+ callExpressionPaths.push(p);
62
+ }
63
+ }
64
+ });
65
+ if (callExpressionPaths.length > 1) {
66
+ console.log(
67
+ `There are ${callExpressionPaths.length} calls to 'createGraphQLHandler' in '${state.file.opts.filename}'. The automatic extraction of graphql options will fallback to the first usage.`
68
+ );
69
+ return;
70
+ }
71
+ const callExpressionPath = callExpressionPaths[0];
72
+ if (!callExpressionPath) {
73
+ return;
74
+ }
75
+ const options = callExpressionPath.node.arguments[0];
76
+ const optionsConst = optionsConstNode(t, options, state);
77
+ const statementParent = callExpressionPath.getStatementParent();
78
+ if (!statementParent) {
79
+ throw new Error(
80
+ `Unable to find statement parent for graphql function in '${state.file.opts.filename}'`
81
+ );
82
+ }
83
+ statementParent.insertBefore(optionsConst);
84
+ callExpressionPath.node.arguments[0] = t.identifier(exportVariableName);
85
+ }
86
+ }
87
+ };
88
+ }
@@ -0,0 +1,23 @@
1
+ import type { PluginObj, types } from '@babel/core';
2
+ /**
3
+ * This babel plugin will search for import statements that include star `**`
4
+ * in the source part of the statement is a glob, the files that are matched are imported,
5
+ * and appended to an object.
6
+ *
7
+ * @example:
8
+ * Given a directory "src/services" that contains "a.js" and "b.ts", "nested/c.js",
9
+ * will produce the following results:
10
+ * ```js
11
+ * import services from 'src/services/**\/*.{js,ts}'
12
+ * console.log(services)
13
+ * // services.a = require('src/services/a.js')
14
+ * // services.b = require('src/services/b.ts')
15
+ * // services.nested_c = require('src/services/nested/c.js')
16
+ * ```
17
+ */
18
+ export default function ({ types: t }: {
19
+ types: typeof types;
20
+ }, { projectIsEsm }?: {
21
+ projectIsEsm?: boolean;
22
+ }): PluginObj;
23
+ //# sourceMappingURL=babel-plugin-redwood-import-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-redwood-import-dir.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-redwood-import-dir.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAKnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,WACZ,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAAE,EACrC,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACxD,SAAS,CAsFX"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var babel_plugin_redwood_import_dir_exports = {};
30
+ __export(babel_plugin_redwood_import_dir_exports, {
31
+ default: () => babel_plugin_redwood_import_dir_default
32
+ });
33
+ module.exports = __toCommonJS(babel_plugin_redwood_import_dir_exports);
34
+ var import_path = __toESM(require("path"));
35
+ var import_fast_glob = __toESM(require("fast-glob"));
36
+ var import_project_config = require("@redmix/project-config");
37
+ function babel_plugin_redwood_import_dir_default({ types: t }, { projectIsEsm = false } = {}) {
38
+ return {
39
+ name: "babel-plugin-redwood-import-dir",
40
+ visitor: {
41
+ ImportDeclaration(p, state) {
42
+ if (!p.node.source.value.includes("**")) {
43
+ return;
44
+ }
45
+ const nodes = [];
46
+ const importName = p.node.specifiers[0].local.name;
47
+ nodes.push(
48
+ t.variableDeclaration("let", [
49
+ t.variableDeclarator(
50
+ t.identifier(importName),
51
+ t.objectExpression([])
52
+ )
53
+ ])
54
+ );
55
+ const importGlob = (0, import_project_config.importStatementPath)(p.node.source.value);
56
+ const cwd = import_path.default.dirname(state.file.opts.filename);
57
+ const dirFiles = import_fast_glob.default.sync(importGlob, { cwd }).filter((n) => !n.includes(".test.")).filter((n) => !n.includes(".scenarios.")).filter((n) => !n.includes(".d.ts"));
58
+ const staticGlob = importGlob.split("*")[0];
59
+ const filePathToVarName = (filePath) => {
60
+ return filePath.replace(staticGlob, "").replace(/\.(js|ts)$/, "").replace(/[^a-zA-Z0-9]/g, "_");
61
+ };
62
+ for (const filePath of dirFiles) {
63
+ const { dir: fileDir, name: fileName } = import_path.default.parse(filePath);
64
+ const filePathWithoutExtension = fileDir + "/" + fileName;
65
+ const fpVarName = filePathToVarName(filePath);
66
+ nodes.push(
67
+ t.importDeclaration(
68
+ [
69
+ t.importNamespaceSpecifier(
70
+ t.identifier(importName + "_" + fpVarName)
71
+ )
72
+ ],
73
+ t.stringLiteral(
74
+ projectIsEsm ? `${filePathWithoutExtension}.js` : filePathWithoutExtension
75
+ )
76
+ )
77
+ );
78
+ nodes.push(
79
+ t.expressionStatement(
80
+ t.assignmentExpression(
81
+ "=",
82
+ t.memberExpression(
83
+ t.identifier(importName),
84
+ t.identifier(fpVarName)
85
+ ),
86
+ t.identifier(importName + "_" + fpVarName)
87
+ )
88
+ )
89
+ );
90
+ }
91
+ for (const node of nodes) {
92
+ p.insertBefore(node);
93
+ }
94
+ p.remove();
95
+ }
96
+ }
97
+ };
98
+ }
@@ -0,0 +1,5 @@
1
+ import type { PluginObj, types as babelTypes } from '@babel/core';
2
+ export default function ({ types }: {
3
+ types: typeof babelTypes;
4
+ }): PluginObj;
5
+ //# sourceMappingURL=babel-plugin-redwood-job-path-injector.d.ts.map