@cedarjs/babel-config 5.0.3 → 5.0.4-next.167
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/dist/api.d.ts +42 -10
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +84 -111
- package/dist/common.d.ts +2 -10
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +20 -75
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -48
- package/dist/plugins/{babel-plugin-redwood-context-wrapping.d.ts → babel-plugin-handler-als-wrapping.d.ts} +1 -1
- package/dist/plugins/babel-plugin-handler-als-wrapping.d.ts.map +1 -0
- package/dist/plugins/{babel-plugin-redwood-context-wrapping.js → babel-plugin-handler-als-wrapping.js} +19 -39
- package/dist/plugins/babel-plugin-redwood-directory-named-import.js +9 -39
- package/dist/plugins/babel-plugin-redwood-import-dir.js +10 -40
- package/dist/plugins/babel-plugin-redwood-job-path-injector.js +7 -37
- package/dist/plugins/babel-plugin-redwood-mock-cell-data.d.ts.map +1 -1
- package/dist/plugins/babel-plugin-redwood-mock-cell-data.js +19 -52
- package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.js +3 -23
- package/dist/plugins/babel-plugin-redwood-routes-auto-loader.js +27 -51
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +48 -71
- package/package.json +7 -7
- package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts +0 -32
- package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts.map +0 -1
- package/dist/plugins/babel-plugin-cedar-gqlorm-inject.js +0 -154
- package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts +0 -5
- package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts.map +0 -1
- package/dist/plugins/babel-plugin-cedar-graphql-options-extract.js +0 -88
- package/dist/plugins/babel-plugin-redwood-context-wrapping.d.ts.map +0 -1
- package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts +0 -5
- package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts.map +0 -1
- package/dist/plugins/babel-plugin-redwood-otel-wrapping.js +0 -329
- package/dist/plugins/prettier.config.js +0 -28
package/dist/api.d.ts
CHANGED
|
@@ -6,27 +6,59 @@ export declare const getApiSideBabelPresets: ({ presetEnv }?: {
|
|
|
6
6
|
}) => TransformOptions["presets"];
|
|
7
7
|
export type PluginList = PluginShape[];
|
|
8
8
|
type PluginShape = [PluginTarget, PluginOptions, undefined | string] | [PluginTarget, PluginOptions];
|
|
9
|
-
export declare const getApiSideBabelPlugins: ({
|
|
10
|
-
|
|
9
|
+
export declare const getApiSideBabelPlugins: ({ forVite, projectIsEsm, }?: {
|
|
10
|
+
forVite?: boolean | undefined;
|
|
11
11
|
projectIsEsm?: boolean | undefined;
|
|
12
|
-
}) =>
|
|
12
|
+
}) => PluginList;
|
|
13
|
+
/**
|
|
14
|
+
* Purpose-built equivalent of `getApiSideBabelPlugins({ forVite: true })` for
|
|
15
|
+
* the Vite-driven api pipelines (buildCedarApp, the api dev middleware, and
|
|
16
|
+
* the esbuild/standalone-Vite api builds in @cedarjs/internal).
|
|
17
|
+
*
|
|
18
|
+
* Every Cedar-specific Babel plugin is gated behind `!forVite` in
|
|
19
|
+
* `getApiSideBabelPlugins` because these pipelines replace them with
|
|
20
|
+
* dedicated Vite/esbuild transforms:
|
|
21
|
+
* - JSX/TypeScript compilation: handled natively by Vite/esbuild
|
|
22
|
+
* - babel-plugin-module-resolver (`src/` and tsconfig `paths` aliases):
|
|
23
|
+
* cedar-api-src-redirect + vite-tsconfig-paths (Vite) or applySrcAlias +
|
|
24
|
+
* applyTsconfigPaths (esbuild); ESM extension rewriting is covered by
|
|
25
|
+
* applyEsmExtensions
|
|
26
|
+
* - directory-named imports: cedarDirectoryNamedImportPlugin /
|
|
27
|
+
* applyDirectoryNamedImport
|
|
28
|
+
* - auto-imports (gql, context): cedarAutoImportsPlugin / applyAutoImports
|
|
29
|
+
* - graphql-tag: vite-plugin-graphql-tag
|
|
30
|
+
* - glob imports: cedarImportDirPlugin / applyImportDir
|
|
31
|
+
*
|
|
32
|
+
* Only the common plugins remain — and that list is currently empty, which
|
|
33
|
+
* is why the Vite pipelines skip Babel entirely unless the project has a
|
|
34
|
+
* custom api/babel.config.js.
|
|
35
|
+
*
|
|
36
|
+
* The `projectIsEsm` option needs no equivalent here: it only affects the
|
|
37
|
+
* module-resolver `resolvePath` hook, which is a `!forVite` plugin.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getApiSideBabelPluginsForVite: () => PluginList;
|
|
13
40
|
export declare const getApiSideBabelConfigPath: () => string | undefined;
|
|
14
|
-
export declare const getApiSideBabelOverrides: ({ projectIsEsm, forJest, }?: {
|
|
41
|
+
export declare const getApiSideBabelOverrides: ({ forVite, projectIsEsm, forJest, }?: {
|
|
42
|
+
forVite?: boolean | undefined;
|
|
15
43
|
projectIsEsm?: boolean | undefined;
|
|
16
44
|
forJest?: boolean | undefined;
|
|
17
45
|
}) => TransformOptions[];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The default api-side Babel config for Jest (@cedarjs/testing) and the
|
|
48
|
+
* Babel ESLint parser (@cedarjs/eslint-config). The Jest-only handler ALS
|
|
49
|
+
* wrapping override is always included: it only matches api/src/functions
|
|
50
|
+
* files, and for the parse-only ESLint consumer transform plugins have no
|
|
51
|
+
* effect.
|
|
52
|
+
*/
|
|
53
|
+
export declare const getApiSideDefaultBabelConfig: () => {
|
|
22
54
|
presets: import("@babel/core").PluginItem[] | null | undefined;
|
|
23
|
-
plugins:
|
|
55
|
+
plugins: PluginList;
|
|
24
56
|
overrides: TransformOptions[];
|
|
25
57
|
extends: string | undefined;
|
|
26
58
|
babelrc: boolean;
|
|
27
59
|
ignore: string[];
|
|
28
60
|
};
|
|
29
61
|
export declare const registerApiSideBabelHook: ({ plugins, ...rest }?: RegisterHookOptions) => void;
|
|
30
|
-
export declare const transformWithBabel: (sourceCode: string, filename: string, plugins: TransformOptions["plugins"], sourceMaps?: TransformOptions["sourceMaps"]) => Promise<import("@babel/core").BabelFileResult | null>;
|
|
62
|
+
export declare const transformWithBabel: (sourceCode: string, filename: string, plugins: TransformOptions["plugins"], sourceMaps?: TransformOptions["sourceMaps"], forVite?: boolean, inputSourceMap?: TransformOptions["inputSourceMap"]) => Promise<import("@babel/core").BabelFileResult | null>;
|
|
31
63
|
export {};
|
|
32
64
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAMhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAMhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAWtD,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC,eAAO,MAAM,sBAAsB,GACjC;;CAAoC,KAqBf,gBAAgB,CAAC,SAAS,CAChD,CAAA;AAKD,MAAM,MAAM,UAAU,GAAG,WAAW,EAAE,CAAA;AACtC,KAAK,WAAW,GACZ,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,GAAG,MAAM,CAAC,GACjD,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;AAEjC,eAAO,MAAM,sBAAsB,GAAI;;;CAGjC,eA6GL,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,6BAA6B,QAAO,UAEhD,CAAA;AAED,eAAO,MAAM,yBAAyB,0BAOrC,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI;;;;CAInC,KAwBgB,gBAAgB,EACrC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B;;;;;;;CASxC,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,uBAGtC,mBAAwB,SAgB1B,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,YAAY,MAAM,EAClB,UAAU,MAAM,EAChB,SAAS,gBAAgB,CAAC,SAAS,CAAC,EACpC,aAAY,gBAAgB,CAAC,YAAY,CAAY,EACrD,iBAAe,EAIf,iBAAgB,gBAAgB,CAAC,gBAAgB,CAAa,0DAuB/D,CAAA"}
|
package/dist/api.js
CHANGED
|
@@ -1,56 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 api_exports = {};
|
|
30
|
-
__export(api_exports, {
|
|
31
|
-
TARGETS_NODE: () => TARGETS_NODE,
|
|
32
|
-
getApiSideBabelConfigPath: () => getApiSideBabelConfigPath,
|
|
33
|
-
getApiSideBabelOverrides: () => getApiSideBabelOverrides,
|
|
34
|
-
getApiSideBabelPlugins: () => getApiSideBabelPlugins,
|
|
35
|
-
getApiSideBabelPresets: () => getApiSideBabelPresets,
|
|
36
|
-
getApiSideDefaultBabelConfig: () => getApiSideDefaultBabelConfig,
|
|
37
|
-
registerApiSideBabelHook: () => registerApiSideBabelHook,
|
|
38
|
-
transformWithBabel: () => transformWithBabel
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(api_exports);
|
|
41
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
42
|
-
var import_node_path = __toESM(require("node:path"));
|
|
43
|
-
var import_core = require("@babel/core");
|
|
44
|
-
var import_babel_plugin_module_resolver = require("babel-plugin-module-resolver");
|
|
45
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
46
|
-
var import_common = require("./common.js");
|
|
47
|
-
var import_babel_plugin_cedar_gqlorm_inject = __toESM(require("./plugins/babel-plugin-cedar-gqlorm-inject.js"));
|
|
48
|
-
var import_babel_plugin_cedar_graphql_options_extract = __toESM(require("./plugins/babel-plugin-cedar-graphql-options-extract.js"));
|
|
49
|
-
var import_babel_plugin_redwood_context_wrapping = __toESM(require("./plugins/babel-plugin-redwood-context-wrapping.js"));
|
|
50
|
-
var import_babel_plugin_redwood_directory_named_import = __toESM(require("./plugins/babel-plugin-redwood-directory-named-import.js"));
|
|
51
|
-
var import_babel_plugin_redwood_import_dir = __toESM(require("./plugins/babel-plugin-redwood-import-dir.js"));
|
|
52
|
-
var import_babel_plugin_redwood_job_path_injector = __toESM(require("./plugins/babel-plugin-redwood-job-path-injector.js"));
|
|
53
|
-
var import_babel_plugin_redwood_otel_wrapping = __toESM(require("./plugins/babel-plugin-redwood-otel-wrapping.js"));
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { transformAsync } from "@babel/core";
|
|
4
|
+
import { resolvePath } from "babel-plugin-module-resolver";
|
|
5
|
+
import { getPaths, projectSideIsEsm } from "@cedarjs/project-config";
|
|
6
|
+
import {
|
|
7
|
+
getPathsFromTypeScriptConfig,
|
|
8
|
+
parseTypeScriptConfigFiles,
|
|
9
|
+
registerBabel
|
|
10
|
+
} from "./common.js";
|
|
11
|
+
import handlerAlsWrappingPlugin from "./plugins/babel-plugin-handler-als-wrapping.js";
|
|
12
|
+
import pluginRedwoodDirectoryNamedImport from "./plugins/babel-plugin-redwood-directory-named-import.js";
|
|
13
|
+
import pluginRedwoodImportDir from "./plugins/babel-plugin-redwood-import-dir.js";
|
|
14
|
+
import pluginRedwoodJobPathInjector from "./plugins/babel-plugin-redwood-job-path-injector.js";
|
|
54
15
|
const TARGETS_NODE = "24";
|
|
55
16
|
const getApiSideBabelPresets = ({ presetEnv } = { presetEnv: false }) => {
|
|
56
17
|
return [
|
|
@@ -75,25 +36,34 @@ const getApiSideBabelPresets = ({ presetEnv } = { presetEnv: false }) => {
|
|
|
75
36
|
].filter(Boolean);
|
|
76
37
|
};
|
|
77
38
|
const getApiSideBabelPlugins = ({
|
|
78
|
-
|
|
39
|
+
forVite = false,
|
|
79
40
|
projectIsEsm = false
|
|
80
41
|
} = {}) => {
|
|
81
|
-
|
|
42
|
+
if (forVite) {
|
|
43
|
+
return getApiSideBabelPluginsForVite();
|
|
44
|
+
}
|
|
45
|
+
const tsConfig = parseTypeScriptConfigFiles();
|
|
82
46
|
const plugins = [
|
|
83
|
-
...(0, import_common.getCommonPlugins)(),
|
|
84
47
|
// Needed to support `/** @jsxImportSource custom-jsx-library */`
|
|
85
48
|
// comments in JSX files
|
|
86
49
|
["@babel/plugin-transform-react-jsx", { runtime: "automatic" }],
|
|
87
|
-
|
|
50
|
+
// For the non-Vite consumers this function serves (Jest,
|
|
51
|
+
// registerApiSideBabelHook / Babel registerRequire paths such as
|
|
52
|
+
// data-migrate CJS and prerender CJS):
|
|
53
|
+
// • alias config: rewrites `src/` and tsconfig paths to relative paths
|
|
54
|
+
// • resolvePath: appends `.js`/`.jsx` to extensionless imports in ESM
|
|
55
|
+
// projects so Node's module resolver can find them, and strips `.js`
|
|
56
|
+
// suffixes in data-migrate / prerender contexts where the TypeScript
|
|
57
|
+
// source is `.ts` but callers write `.js` import specifiers.
|
|
88
58
|
[
|
|
89
59
|
"babel-plugin-module-resolver",
|
|
90
60
|
{
|
|
91
61
|
alias: {
|
|
92
62
|
src: "./src",
|
|
93
63
|
// adds the paths from [ts|js]config.json to the module resolver
|
|
94
|
-
...
|
|
64
|
+
...getPathsFromTypeScriptConfig(tsConfig.api, getPaths().api.base)
|
|
95
65
|
},
|
|
96
|
-
root: [
|
|
66
|
+
root: [getPaths().api.base],
|
|
97
67
|
cwd: "packagejson",
|
|
98
68
|
loglevel: "silent",
|
|
99
69
|
// to silence the unnecessary warnings
|
|
@@ -101,16 +71,16 @@ const getApiSideBabelPlugins = ({
|
|
|
101
71
|
const isDataMigrate = process.argv[2] === "data-migrate";
|
|
102
72
|
const isPrerender = process.argv[2] === "prerender";
|
|
103
73
|
const importPath = /.*\/.*\.js$/.test(sourcePath) && (isDataMigrate || isPrerender) ? sourcePath.replace(/\.js$/, "") : sourcePath;
|
|
104
|
-
const resolvedPath =
|
|
74
|
+
const resolvedPath = resolvePath(importPath, currentFile, opts);
|
|
105
75
|
if (!resolvedPath || !projectIsEsm || resolvedPath.includes("/**/")) {
|
|
106
76
|
return resolvedPath;
|
|
107
77
|
}
|
|
108
|
-
const currentFileDir =
|
|
109
|
-
const joinedPath =
|
|
110
|
-
if (
|
|
78
|
+
const currentFileDir = path.dirname(currentFile);
|
|
79
|
+
const joinedPath = path.join(currentFileDir, resolvedPath);
|
|
80
|
+
if (fs.existsSync(joinedPath + ".js") || fs.existsSync(joinedPath + ".ts")) {
|
|
111
81
|
return resolvedPath + ".js";
|
|
112
82
|
}
|
|
113
|
-
if (
|
|
83
|
+
if (fs.existsSync(joinedPath + ".jsx") || fs.existsSync(joinedPath + ".tsx")) {
|
|
114
84
|
return resolvedPath + ".jsx";
|
|
115
85
|
}
|
|
116
86
|
return resolvedPath;
|
|
@@ -118,11 +88,16 @@ const getApiSideBabelPlugins = ({
|
|
|
118
88
|
},
|
|
119
89
|
"rwjs-api-module-resolver"
|
|
120
90
|
],
|
|
91
|
+
// Vite/esbuild use cedarDirectoryNamedImportPlugin / applyDirectoryNamedImport
|
|
92
|
+
// instead of this babel plugin
|
|
121
93
|
[
|
|
122
|
-
|
|
94
|
+
pluginRedwoodDirectoryNamedImport,
|
|
123
95
|
void 0,
|
|
124
96
|
"rwjs-babel-directory-named-modules"
|
|
125
97
|
],
|
|
98
|
+
// Auto-import is handled by cedarAutoImportsPlugin / applyAutoImports for
|
|
99
|
+
// Vite/esbuild; this Babel plugin serves the remaining non-Vite consumers
|
|
100
|
+
// (Jest, registerApiSideBabelHook).
|
|
126
101
|
[
|
|
127
102
|
"babel-plugin-auto-import",
|
|
128
103
|
{
|
|
@@ -141,68 +116,60 @@ const getApiSideBabelPlugins = ({
|
|
|
141
116
|
},
|
|
142
117
|
"rwjs-babel-auto-import"
|
|
143
118
|
],
|
|
144
|
-
// FIXME: `graphql-tag` is not working: https://github.com/redwoodjs/redwood/pull/3193
|
|
145
119
|
["babel-plugin-graphql-tag", void 0, "rwjs-babel-graphql-tag"],
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"rwjs-babel-otel-wrapping"
|
|
151
|
-
]
|
|
120
|
+
// For Vite builds, glob imports are handled by cedarImportDirPlugin (Vite)
|
|
121
|
+
// or applyImportDir (esbuild). Keep the Babel plugin only for
|
|
122
|
+
// non-Vite consumers: Jest, console, and data-migrate.
|
|
123
|
+
[pluginRedwoodImportDir, {}, "rwjs-babel-glob-import-dir"]
|
|
152
124
|
];
|
|
153
|
-
return plugins
|
|
125
|
+
return plugins;
|
|
126
|
+
};
|
|
127
|
+
const getApiSideBabelPluginsForVite = () => {
|
|
128
|
+
return [];
|
|
154
129
|
};
|
|
155
130
|
const getApiSideBabelConfigPath = () => {
|
|
156
|
-
const p =
|
|
157
|
-
if (
|
|
131
|
+
const p = path.join(getPaths().api.base, "babel.config.js");
|
|
132
|
+
if (fs.existsSync(p)) {
|
|
158
133
|
return p;
|
|
159
134
|
} else {
|
|
160
135
|
return;
|
|
161
136
|
}
|
|
162
137
|
};
|
|
163
138
|
const getApiSideBabelOverrides = ({
|
|
139
|
+
forVite = false,
|
|
164
140
|
projectIsEsm = false,
|
|
165
141
|
forJest = false
|
|
166
142
|
} = {}) => {
|
|
167
143
|
const overrides = [
|
|
168
|
-
//
|
|
169
|
-
//
|
|
170
|
-
{
|
|
171
|
-
// match */api/src/functions/graphql.js|ts
|
|
172
|
-
test: /.+api(?:[\\|/])src(?:[\\|/])functions(?:[\\|/])graphql\.(?:js|ts)$/,
|
|
173
|
-
plugins: [import_babel_plugin_cedar_graphql_options_extract.default, import_babel_plugin_cedar_gqlorm_inject.default]
|
|
174
|
-
},
|
|
175
|
-
// Apply context wrapping to all functions (Jest only; Vite uses
|
|
176
|
-
// cedarContextWrappingPlugin instead)
|
|
144
|
+
// Apply handler ALS wrapping to all functions (Jest only; Vite uses
|
|
145
|
+
// handlerAlsWrappingPlugin instead)
|
|
177
146
|
forJest && {
|
|
178
147
|
// match */api/src/functions/*.js|ts
|
|
179
148
|
test: /.+api(?:[\\|/])src(?:[\\|/])functions(?:[\\|/]).+.(?:js|ts)$/,
|
|
180
149
|
plugins: [
|
|
181
150
|
[
|
|
182
|
-
|
|
151
|
+
handlerAlsWrappingPlugin,
|
|
183
152
|
{
|
|
184
153
|
projectIsEsm
|
|
185
154
|
}
|
|
186
155
|
]
|
|
187
156
|
]
|
|
188
157
|
},
|
|
189
|
-
// Add import names and paths to job definitions
|
|
190
|
-
|
|
158
|
+
// Add import names and paths to job definitions. Vite uses
|
|
159
|
+
// cedarjsJobPathInjectorPlugin instead.
|
|
160
|
+
!forVite && {
|
|
191
161
|
// match */api/src/jobs/*.js|ts
|
|
192
162
|
test: /.+api(?:[\\|/])src(?:[\\|/])jobs(?:[\\|/]).+.(?:js|ts)$/,
|
|
193
|
-
plugins: [[
|
|
163
|
+
plugins: [[pluginRedwoodJobPathInjector]]
|
|
194
164
|
}
|
|
195
165
|
].filter(Boolean);
|
|
196
166
|
return overrides;
|
|
197
167
|
};
|
|
198
|
-
const getApiSideDefaultBabelConfig = ({
|
|
199
|
-
projectIsEsm = false,
|
|
200
|
-
forJest = false
|
|
201
|
-
} = {}) => {
|
|
168
|
+
const getApiSideDefaultBabelConfig = () => {
|
|
202
169
|
return {
|
|
203
170
|
presets: getApiSideBabelPresets(),
|
|
204
|
-
plugins: getApiSideBabelPlugins(
|
|
205
|
-
overrides: getApiSideBabelOverrides({
|
|
171
|
+
plugins: getApiSideBabelPlugins(),
|
|
172
|
+
overrides: getApiSideBabelOverrides({ forJest: true }),
|
|
206
173
|
extends: getApiSideBabelConfigPath(),
|
|
207
174
|
babelrc: false,
|
|
208
175
|
ignore: ["node_modules"]
|
|
@@ -212,45 +179,51 @@ const registerApiSideBabelHook = ({
|
|
|
212
179
|
plugins = [],
|
|
213
180
|
...rest
|
|
214
181
|
} = {}) => {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
(0, import_common.registerBabel)({
|
|
219
|
-
...defaultOptions,
|
|
182
|
+
const projectIsEsm = projectSideIsEsm("api");
|
|
183
|
+
registerBabel({
|
|
220
184
|
presets: getApiSideBabelPresets({
|
|
221
185
|
presetEnv: true
|
|
222
186
|
}),
|
|
187
|
+
overrides: getApiSideBabelOverrides({ projectIsEsm }),
|
|
188
|
+
extends: getApiSideBabelConfigPath(),
|
|
189
|
+
babelrc: false,
|
|
190
|
+
ignore: ["node_modules"],
|
|
223
191
|
extensions: [".js", ".ts", ".jsx", ".tsx"],
|
|
224
|
-
plugins: [...
|
|
192
|
+
plugins: [...getApiSideBabelPlugins({ projectIsEsm }), ...plugins],
|
|
225
193
|
cache: false,
|
|
226
194
|
...rest
|
|
227
195
|
});
|
|
228
196
|
};
|
|
229
|
-
const transformWithBabel = async (sourceCode, filename, plugins, sourceMaps = "inline") => {
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
197
|
+
const transformWithBabel = async (sourceCode, filename, plugins, sourceMaps = "inline", forVite = false, inputSourceMap = void 0) => {
|
|
198
|
+
const result = transformAsync(sourceCode, {
|
|
199
|
+
presets: getApiSideBabelPresets(),
|
|
200
|
+
overrides: getApiSideBabelOverrides({
|
|
201
|
+
forVite,
|
|
202
|
+
projectIsEsm: projectSideIsEsm("api")
|
|
203
|
+
}),
|
|
204
|
+
extends: getApiSideBabelConfigPath(),
|
|
205
|
+
babelrc: false,
|
|
206
|
+
ignore: ["node_modules"],
|
|
207
|
+
cwd: getPaths().api.base,
|
|
236
208
|
filename,
|
|
237
209
|
// The default 'inline' embeds the map as a data URL in result.code,
|
|
238
210
|
// which esbuild consumes when it reads from the result. Vite callers
|
|
239
211
|
// pass sourceMaps: true because they extract result.map separately for
|
|
240
212
|
// SSR source map chaining.
|
|
241
213
|
sourceMaps,
|
|
242
|
-
plugins
|
|
214
|
+
plugins,
|
|
215
|
+
inputSourceMap
|
|
243
216
|
});
|
|
244
217
|
return result;
|
|
245
218
|
};
|
|
246
|
-
|
|
247
|
-
0 && (module.exports = {
|
|
219
|
+
export {
|
|
248
220
|
TARGETS_NODE,
|
|
249
221
|
getApiSideBabelConfigPath,
|
|
250
222
|
getApiSideBabelOverrides,
|
|
251
223
|
getApiSideBabelPlugins,
|
|
224
|
+
getApiSideBabelPluginsForVite,
|
|
252
225
|
getApiSideBabelPresets,
|
|
253
226
|
getApiSideDefaultBabelConfig,
|
|
254
227
|
registerApiSideBabelHook,
|
|
255
228
|
transformWithBabel
|
|
256
|
-
}
|
|
229
|
+
};
|
package/dist/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginItem,
|
|
1
|
+
import type { PluginItem, TransformOptions } from '@babel/core';
|
|
2
2
|
import type { RegisterOptions } from '@babel/register';
|
|
3
3
|
import type { Flags as WebFlags } from './web.js';
|
|
4
4
|
export interface RegisterHookOptions {
|
|
@@ -16,15 +16,7 @@ export interface BabelRegisterOptions extends TransformOptions {
|
|
|
16
16
|
cache?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare const registerBabel: (options: RegisterOptions) => void;
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const getRouteHookBabelPlugins: () => (TransformOptions | (string | {
|
|
21
|
-
alias: {
|
|
22
|
-
'api/src': string;
|
|
23
|
-
};
|
|
24
|
-
root: string[];
|
|
25
|
-
cwd: string;
|
|
26
|
-
loglevel: string;
|
|
27
|
-
})[])[];
|
|
19
|
+
export declare const getRouteHookBabelPlugins: () => TransformOptions[];
|
|
28
20
|
/**
|
|
29
21
|
* Finds, reads and parses the [ts|js]config.json file
|
|
30
22
|
* @returns The config object
|
package/dist/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAMtD,OAAO,KAAK,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,UAAU,CAAA;AAOjD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,SAAS,CAAC,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACzC,OAAO,CAAC,EAAE,QAAQ,CAAA;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAkBD,eAAO,MAAM,aAAa,GAAI,SAAS,eAAe,SAOrD,CAAA;AAID,eAAO,MAAM,wBAAwB,0BAEpC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;CAuBtC,CAAA;AAED,KAAK,uBAAuB,GAAG;IAC7B,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACtE,CAAA;AACD;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,uBAAuB,EAC/B,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAqCvB,CAAA"}
|
package/dist/common.js
CHANGED
|
@@ -1,82 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 common_exports = {};
|
|
30
|
-
__export(common_exports, {
|
|
31
|
-
getCommonPlugins: () => getCommonPlugins,
|
|
32
|
-
getPathsFromTypeScriptConfig: () => getPathsFromTypeScriptConfig,
|
|
33
|
-
getRouteHookBabelPlugins: () => getRouteHookBabelPlugins,
|
|
34
|
-
parseTypeScriptConfigFiles: () => parseTypeScriptConfigFiles,
|
|
35
|
-
registerBabel: () => registerBabel
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(common_exports);
|
|
38
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
39
|
-
var import_path = __toESM(require("path"));
|
|
40
|
-
var import_typescript = require("typescript");
|
|
41
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
42
|
-
var import_web = require("./web.js");
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { parseConfigFileTextToJson } from "typescript";
|
|
5
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
+
import { getWebSideBabelPlugins } from "./web.js";
|
|
7
|
+
const require2 = createRequire(import.meta.url);
|
|
43
8
|
const registerBabel = (options) => {
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
const getCommonPlugins = () => {
|
|
47
|
-
return [];
|
|
9
|
+
require2("@babel/register")(options);
|
|
48
10
|
};
|
|
49
11
|
const getRouteHookBabelPlugins = () => {
|
|
50
|
-
return [
|
|
51
|
-
...(0, import_web.getWebSideBabelPlugins)(),
|
|
52
|
-
[
|
|
53
|
-
"babel-plugin-module-resolver",
|
|
54
|
-
{
|
|
55
|
-
alias: {
|
|
56
|
-
"api/src": "./src"
|
|
57
|
-
},
|
|
58
|
-
root: [(0, import_project_config.getPaths)().api.base],
|
|
59
|
-
cwd: "packagejson",
|
|
60
|
-
loglevel: "silent"
|
|
61
|
-
// to silence the unnecessary warnings
|
|
62
|
-
},
|
|
63
|
-
"rwjs-api-module-resolver"
|
|
64
|
-
]
|
|
65
|
-
];
|
|
12
|
+
return [...getWebSideBabelPlugins()];
|
|
66
13
|
};
|
|
67
14
|
const parseTypeScriptConfigFiles = () => {
|
|
68
|
-
const rwPaths =
|
|
15
|
+
const rwPaths = getPaths();
|
|
69
16
|
const parseConfigFile = (basePath) => {
|
|
70
|
-
let configPath =
|
|
71
|
-
if (!
|
|
72
|
-
configPath =
|
|
73
|
-
if (!
|
|
17
|
+
let configPath = path.join(basePath, "tsconfig.json");
|
|
18
|
+
if (!fs.existsSync(configPath)) {
|
|
19
|
+
configPath = path.join(basePath, "jsconfig.json");
|
|
20
|
+
if (!fs.existsSync(configPath)) {
|
|
74
21
|
return null;
|
|
75
22
|
}
|
|
76
23
|
}
|
|
77
|
-
return
|
|
24
|
+
return parseConfigFileTextToJson(
|
|
78
25
|
configPath,
|
|
79
|
-
|
|
26
|
+
fs.readFileSync(configPath, "utf-8")
|
|
80
27
|
);
|
|
81
28
|
};
|
|
82
29
|
const apiConfig = parseConfigFile(rwPaths.api.base);
|
|
@@ -96,7 +43,7 @@ const getPathsFromTypeScriptConfig = (config, rootDir) => {
|
|
|
96
43
|
const { baseUrl, paths } = config.compilerOptions;
|
|
97
44
|
let absoluteBase;
|
|
98
45
|
if (baseUrl) {
|
|
99
|
-
absoluteBase =
|
|
46
|
+
absoluteBase = path.isAbsolute(baseUrl) ? baseUrl : path.join(rootDir, baseUrl);
|
|
100
47
|
} else {
|
|
101
48
|
absoluteBase = rootDir;
|
|
102
49
|
}
|
|
@@ -106,16 +53,14 @@ const getPathsFromTypeScriptConfig = (config, rootDir) => {
|
|
|
106
53
|
continue;
|
|
107
54
|
}
|
|
108
55
|
const aliasKey = key.replace("/*", "");
|
|
109
|
-
const aliasValue =
|
|
56
|
+
const aliasValue = path.join(absoluteBase, value[0].replace("/*", ""));
|
|
110
57
|
pathsObj[aliasKey] = aliasValue;
|
|
111
58
|
}
|
|
112
59
|
return pathsObj;
|
|
113
60
|
};
|
|
114
|
-
|
|
115
|
-
0 && (module.exports = {
|
|
116
|
-
getCommonPlugins,
|
|
61
|
+
export {
|
|
117
62
|
getPathsFromTypeScriptConfig,
|
|
118
63
|
getRouteHookBabelPlugins,
|
|
119
64
|
parseTypeScriptConfigFiles,
|
|
120
65
|
registerBabel
|
|
121
|
-
}
|
|
66
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -11,11 +11,13 @@ TARGETS_NODE,
|
|
|
11
11
|
getApiSideBabelConfigPath,
|
|
12
12
|
/** Used by @cedarjs/internal and @cedarjs/testing */
|
|
13
13
|
getApiSideBabelPlugins,
|
|
14
|
+
/** Used by @cedarjs/internal and @cedarjs/vite */
|
|
15
|
+
getApiSideBabelPluginsForVite,
|
|
14
16
|
/** Used by @cedarjs/testing */
|
|
15
17
|
getApiSideBabelPresets,
|
|
16
18
|
/** Used by @cedarjs/testing and @cedarjs/eslint-config */
|
|
17
19
|
getApiSideDefaultBabelConfig,
|
|
18
|
-
/** Used by @cedarjs/cli, @
|
|
20
|
+
/** Used by @cedarjs/cli, @cedarjs/cli-helpers and @cedarjs/prerender */
|
|
19
21
|
registerApiSideBabelHook,
|
|
20
22
|
/** Used by @cedarjs/internal and @cedarjs/vite */
|
|
21
23
|
transformWithBabel, } from './api.js';
|
|
@@ -46,8 +48,6 @@ getWebSideOverrides,
|
|
|
46
48
|
registerWebSideBabelHook, } from './web.js';
|
|
47
49
|
export type { Flags } from './web.js';
|
|
48
50
|
export {
|
|
49
|
-
/** Used by our eslint-config */
|
|
50
|
-
getCommonPlugins,
|
|
51
51
|
/**
|
|
52
52
|
* @deprecated This export isn't used by the framework, so it'll be removed
|
|
53
53
|
* in a future version.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO;AACL;;;GAGG;AACH,YAAY;AACZ;;;GAGG;AACH,yBAAyB;AACzB,qDAAqD;AACrD,sBAAsB;AACtB,+BAA+B;AAC/B,sBAAsB;AACtB,0DAA0D;AAC1D,4BAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO;AACL;;;GAGG;AACH,YAAY;AACZ;;;GAGG;AACH,yBAAyB;AACzB,qDAAqD;AACrD,sBAAsB;AACtB,kDAAkD;AAClD,6BAA6B;AAC7B,+BAA+B;AAC/B,sBAAsB;AACtB,0DAA0D;AAC1D,4BAA4B;AAC5B,wEAAwE;AACxE,wBAAwB;AACxB,kDAAkD;AAClD,kBAAkB,GACnB,MAAM,UAAU,CAAA;AAEjB,OAAO;AACL;;;GAGG;AACH,yBAAyB;AACzB;;;GAGG;AACH,sBAAsB;AACtB;;;GAGG;AACH,sBAAsB;AACtB,mEAAmE;AACnE,4BAA4B;AAC5B;;;GAGG;AACH,mBAAmB;AACnB,iCAAiC;AACjC,wBAAwB,GACzB,MAAM,UAAU,CAAA;AAEjB,YAAY,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,OAAO;AACL;;;GAGG;AACH,4BAA4B,IAAI,kBAAkB;AAClD,mBAAmB;AACnB,wBAAwB;AACxB;;;GAGG;AACH,0BAA0B;AAC1B;;;GAGG;AACH,aAAa,GACd,MAAM,aAAa,CAAA"}
|