@cedarjs/babel-config 5.0.4-next.167 → 5.0.4
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 +10 -42
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +111 -84
- package/dist/common.d.ts +10 -2
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +75 -20
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -28
- package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts +32 -0
- package/dist/plugins/babel-plugin-cedar-gqlorm-inject.d.ts.map +1 -0
- package/dist/plugins/babel-plugin-cedar-gqlorm-inject.js +154 -0
- package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts +5 -0
- package/dist/plugins/babel-plugin-cedar-graphql-options-extract.d.ts.map +1 -0
- package/dist/plugins/babel-plugin-cedar-graphql-options-extract.js +88 -0
- package/dist/plugins/{babel-plugin-handler-als-wrapping.d.ts → babel-plugin-redwood-context-wrapping.d.ts} +1 -1
- package/dist/plugins/babel-plugin-redwood-context-wrapping.d.ts.map +1 -0
- package/dist/plugins/{babel-plugin-handler-als-wrapping.js → babel-plugin-redwood-context-wrapping.js} +39 -19
- package/dist/plugins/babel-plugin-redwood-directory-named-import.js +39 -9
- package/dist/plugins/babel-plugin-redwood-import-dir.js +40 -10
- package/dist/plugins/babel-plugin-redwood-job-path-injector.js +37 -7
- package/dist/plugins/babel-plugin-redwood-mock-cell-data.d.ts.map +1 -1
- package/dist/plugins/babel-plugin-redwood-mock-cell-data.js +52 -19
- package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts +5 -0
- package/dist/plugins/babel-plugin-redwood-otel-wrapping.d.ts.map +1 -0
- package/dist/plugins/babel-plugin-redwood-otel-wrapping.js +329 -0
- package/dist/plugins/babel-plugin-redwood-remove-dev-fatal-error-page.js +23 -3
- package/dist/plugins/babel-plugin-redwood-routes-auto-loader.js +51 -27
- package/dist/plugins/prettier.config.js +28 -0
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +71 -48
- package/package.json +7 -7
- package/dist/plugins/babel-plugin-handler-als-wrapping.d.ts.map +0 -1
|
@@ -1,35 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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_routes_auto_loader_exports = {};
|
|
30
|
+
__export(babel_plugin_redwood_routes_auto_loader_exports, {
|
|
31
|
+
default: () => babel_plugin_redwood_routes_auto_loader_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(babel_plugin_redwood_routes_auto_loader_exports);
|
|
34
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
35
|
+
var import_node_path = __toESM(require("node:path"));
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
10
37
|
const getPathRelativeToSrc = (maybeAbsolutePath) => {
|
|
11
38
|
if (maybeAbsolutePath.startsWith("src/")) {
|
|
12
|
-
const basePath =
|
|
13
|
-
const resolved = resolveFile(basePath) || resolveFile(
|
|
39
|
+
const basePath = import_node_path.default.join((0, import_project_config.getPaths)().web.base, maybeAbsolutePath);
|
|
40
|
+
const resolved = (0, import_project_config.resolveFile)(basePath) || (0, import_project_config.resolveFile)(import_node_path.default.join(basePath, "index")) || (0, import_project_config.resolveFile)(import_node_path.default.join(basePath, import_node_path.default.basename(basePath)));
|
|
14
41
|
if (resolved) {
|
|
15
42
|
const withoutExt = resolved.replace(/\.[^/.]+$/, "");
|
|
16
|
-
return "./" +
|
|
43
|
+
return "./" + import_node_path.default.relative((0, import_project_config.getPaths)().web.src, withoutExt);
|
|
17
44
|
}
|
|
18
45
|
return "./" + maybeAbsolutePath.slice("src/".length);
|
|
19
46
|
}
|
|
20
|
-
if (!
|
|
47
|
+
if (!import_node_path.default.isAbsolute(maybeAbsolutePath)) {
|
|
21
48
|
return maybeAbsolutePath;
|
|
22
49
|
}
|
|
23
|
-
return `./${
|
|
50
|
+
return `./${import_node_path.default.relative((0, import_project_config.getPaths)().web.src, maybeAbsolutePath)}`;
|
|
24
51
|
};
|
|
25
52
|
const withRelativeImports = (page) => {
|
|
26
53
|
return {
|
|
27
54
|
...page,
|
|
28
|
-
relativeImport: ensurePosixPath(getPathRelativeToSrc(page.importPath))
|
|
55
|
+
relativeImport: (0, import_project_config.ensurePosixPath)(getPathRelativeToSrc(page.importPath))
|
|
29
56
|
};
|
|
30
57
|
};
|
|
31
58
|
function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrerender = false }) {
|
|
32
|
-
let pages = processPagesDir().map(withRelativeImports);
|
|
59
|
+
let pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
|
|
33
60
|
const duplicatePageImportNames = /* @__PURE__ */ new Set();
|
|
34
61
|
const sortedPageImportNames = pages.map((page) => page.importName).sort();
|
|
35
62
|
for (let i = 0; i < sortedPageImportNames.length - 1; i++) {
|
|
@@ -55,7 +82,7 @@ function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrer
|
|
|
55
82
|
return;
|
|
56
83
|
}
|
|
57
84
|
const userImportRelativePath = getPathRelativeToSrc(
|
|
58
|
-
importStatementPath(p.node.source?.value)
|
|
85
|
+
(0, import_project_config.importStatementPath)(p.node.source?.value)
|
|
59
86
|
);
|
|
60
87
|
const defaultSpecifier = p.node.specifiers.find(
|
|
61
88
|
(specifiers) => t.isImportDefaultSpecifier(specifiers)
|
|
@@ -65,7 +92,7 @@ function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrer
|
|
|
65
92
|
}
|
|
66
93
|
if (forPrerender) {
|
|
67
94
|
const pageThatUserImported = pages.find((page) => {
|
|
68
|
-
return page.relativeImport === ensurePosixPath(userImportRelativePath);
|
|
95
|
+
return page.relativeImport === (0, import_project_config.ensurePosixPath)(userImportRelativePath);
|
|
69
96
|
});
|
|
70
97
|
if (pageThatUserImported) {
|
|
71
98
|
pageThatUserImported.importName = defaultSpecifier.local.name;
|
|
@@ -77,21 +104,21 @@ function babel_plugin_redwood_routes_auto_loader_default({ types: t }, { forPrer
|
|
|
77
104
|
}
|
|
78
105
|
if (userImportRelativePath && defaultSpecifier) {
|
|
79
106
|
pages = pages.filter(
|
|
80
|
-
(page) => !(page.relativeImport === ensurePosixPath(userImportRelativePath))
|
|
107
|
+
(page) => !(page.relativeImport === (0, import_project_config.ensurePosixPath)(userImportRelativePath))
|
|
81
108
|
);
|
|
82
109
|
}
|
|
83
110
|
},
|
|
84
111
|
Program: {
|
|
85
112
|
enter() {
|
|
86
|
-
pages = processPagesDir().map(withRelativeImports);
|
|
87
|
-
const appPath = resolveFile(
|
|
113
|
+
pages = (0, import_project_config.processPagesDir)().map(withRelativeImports);
|
|
114
|
+
const appPath = (0, import_project_config.resolveFile)(import_node_path.default.join((0, import_project_config.getPaths)().web.src, "App"));
|
|
88
115
|
if (appPath) {
|
|
89
|
-
const appSource =
|
|
116
|
+
const appSource = import_node_fs.default.readFileSync(appPath, "utf8");
|
|
90
117
|
const importRe = /^import\s+\w+\s+from\s+['"]([^'"]+)['"]/gm;
|
|
91
118
|
let m;
|
|
92
119
|
while ((m = importRe.exec(appSource)) !== null) {
|
|
93
|
-
const rel = ensurePosixPath(
|
|
94
|
-
getPathRelativeToSrc(importStatementPath(m[1]))
|
|
120
|
+
const rel = (0, import_project_config.ensurePosixPath)(
|
|
121
|
+
getPathRelativeToSrc((0, import_project_config.importStatementPath)(m[1]))
|
|
95
122
|
);
|
|
96
123
|
pages = pages.filter((page) => page.relativeImport !== rel);
|
|
97
124
|
}
|
|
@@ -168,6 +195,3 @@ function prerenderLoaderImpl(forPrerender, relativeImport, t) {
|
|
|
168
195
|
)
|
|
169
196
|
]);
|
|
170
197
|
}
|
|
171
|
-
export {
|
|
172
|
-
babel_plugin_redwood_routes_auto_loader_default as default
|
|
173
|
-
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const config = {
|
|
3
|
+
bracketSpacing: true,
|
|
4
|
+
tabWidth: 2,
|
|
5
|
+
semi: false,
|
|
6
|
+
singleQuote: true,
|
|
7
|
+
plugins: [
|
|
8
|
+
"prettier-plugin-curly",
|
|
9
|
+
// I have this prettier config here because babel-plugin-tester v11 that
|
|
10
|
+
// we're currently using uses prettier v2, and prettier-plugin-sh requires
|
|
11
|
+
// prettier v3. By putting this prettier config here, babel-plugin-tester
|
|
12
|
+
// will use this, and run its output through prettier without loading the
|
|
13
|
+
// prettier-plugin-sh plugin, which it really doesn't need anyway since
|
|
14
|
+
// we're not asking it to format shell scripts or other shell files.
|
|
15
|
+
// 'prettier-plugin-sh',
|
|
16
|
+
"prettier-plugin-packagejson"
|
|
17
|
+
],
|
|
18
|
+
overrides: [
|
|
19
|
+
{
|
|
20
|
+
files: ["tsconfig.cjs.json"],
|
|
21
|
+
options: {
|
|
22
|
+
parser: "jsonc",
|
|
23
|
+
trailingComma: "none"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
module.exports = config;
|
package/dist/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAUtD,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,sBAAsB,GACjC,uBAAsB,KAA0B,uBAqGjD,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC9B,4BAA2B,KAA+B,KACzD,gBAAgB,EAqClB,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,SAAS,KAAK,qDAwCpD,CAAA;AAED,eAAO,MAAM,yBAAyB,0BAOrC,CAAA;AAED,eAAO,MAAM,4BAA4B,GAAI,UAAS,KAAU;;;;;;;CAa/D,CAAA;AAGD,eAAO,MAAM,wBAAwB,GAAI,mCAItC,mBAAwB,SAY1B,CAAA"}
|
package/dist/web.js
CHANGED
|
@@ -1,37 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 web_exports = {};
|
|
30
|
+
__export(web_exports, {
|
|
31
|
+
getWebSideBabelConfigPath: () => getWebSideBabelConfigPath,
|
|
32
|
+
getWebSideBabelPlugins: () => getWebSideBabelPlugins,
|
|
33
|
+
getWebSideBabelPresets: () => getWebSideBabelPresets,
|
|
34
|
+
getWebSideDefaultBabelConfig: () => getWebSideDefaultBabelConfig,
|
|
35
|
+
getWebSideOverrides: () => getWebSideOverrides,
|
|
36
|
+
registerWebSideBabelHook: () => registerWebSideBabelHook
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(web_exports);
|
|
39
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
40
|
+
var import_node_path = __toESM(require("node:path"));
|
|
41
|
+
var import_babel_plugin_module_resolver = require("babel-plugin-module-resolver");
|
|
42
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
43
|
+
var import_common = require("./common.js");
|
|
12
44
|
const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
|
|
13
|
-
const config = getConfig();
|
|
45
|
+
const config = (0, import_project_config.getConfig)();
|
|
14
46
|
const useReactCompiler = config.experimental?.reactCompiler?.enabled && config.experimental?.reactCompiler?.lintOnly === false;
|
|
15
47
|
const useTrustedDocumentsGqlTag = config.graphql.trustedDocuments;
|
|
16
|
-
const rwjsPaths = getPaths();
|
|
17
|
-
const tsConfigs = parseTypeScriptConfigFiles();
|
|
48
|
+
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
49
|
+
const tsConfigs = (0, import_common.parseTypeScriptConfigFiles)();
|
|
18
50
|
const plugins = [
|
|
19
51
|
// It is important that this plugin run first, as noted here: https://react.dev/learn/react-compiler
|
|
20
52
|
useReactCompiler && ["babel-plugin-react-compiler", { target: "19" }],
|
|
53
|
+
...forJest ? (0, import_common.getCommonPlugins)() : [],
|
|
21
54
|
// === Import path handling
|
|
22
|
-
|
|
23
|
-
// cedarjsResolveCedarStyleImportsPlugin, and tsconfig `paths` aliases via
|
|
24
|
-
// vite-tsconfig-paths, instead of this babel plugin
|
|
25
|
-
!forVite && [
|
|
55
|
+
[
|
|
26
56
|
"babel-plugin-module-resolver",
|
|
27
57
|
{
|
|
28
58
|
alias: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
59
|
+
...!forVite && {
|
|
60
|
+
// Jest monorepo and multi project runner is not correctly
|
|
61
|
+
// determining the `cwd`:
|
|
62
|
+
// https://github.com/facebook/jest/issues/7359
|
|
63
|
+
src: forJest ? rwjsPaths.web.src : "./src"
|
|
64
|
+
},
|
|
33
65
|
// adds the paths from [ts|js]config.json to the module resolver
|
|
34
|
-
...getPathsFromTypeScriptConfig(tsConfigs.web, rwjsPaths.web.base),
|
|
66
|
+
...(0, import_common.getPathsFromTypeScriptConfig)(tsConfigs.web, rwjsPaths.web.base),
|
|
35
67
|
$api: rwjsPaths.api.base
|
|
36
68
|
},
|
|
37
69
|
root: [rwjsPaths.web.base],
|
|
@@ -39,7 +71,7 @@ const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
|
|
|
39
71
|
loglevel: "silent",
|
|
40
72
|
// to silence the unnecessary warnings
|
|
41
73
|
resolvePath(sourcePath, currentFile, opts) {
|
|
42
|
-
const resolvedPath = resolvePath(sourcePath, currentFile, opts);
|
|
74
|
+
const resolvedPath = (0, import_babel_plugin_module_resolver.resolvePath)(sourcePath, currentFile, opts);
|
|
43
75
|
return resolvedPath?.replace(/\.js$/, "");
|
|
44
76
|
}
|
|
45
77
|
},
|
|
@@ -49,14 +81,12 @@ const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
|
|
|
49
81
|
// packages/vite/src/plugins/vite-plugin-cedarjs-resolve-cedar-style-imports.ts
|
|
50
82
|
// instead of this babel plugin
|
|
51
83
|
!forVite && [
|
|
52
|
-
|
|
84
|
+
require("./plugins/babel-plugin-redwood-directory-named-import").default,
|
|
53
85
|
void 0,
|
|
54
86
|
"rwjs-directory-named-modules"
|
|
55
87
|
],
|
|
56
88
|
// === Auto imports, and transforms
|
|
57
|
-
|
|
58
|
-
// non-Vite consumers (Jest web tests).
|
|
59
|
-
!forVite && [
|
|
89
|
+
[
|
|
60
90
|
"babel-plugin-auto-import",
|
|
61
91
|
{
|
|
62
92
|
declarations: [
|
|
@@ -84,15 +114,11 @@ const getWebSideBabelPlugins = ({ forJest, forVite } = { forJest: false }) => {
|
|
|
84
114
|
},
|
|
85
115
|
"rwjs-web-auto-import"
|
|
86
116
|
],
|
|
117
|
+
["babel-plugin-graphql-tag", void 0, "rwjs-babel-graphql-tag"],
|
|
87
118
|
// Prerender uses rollup-plugin-cedar-remove-dev-fatal-error-page
|
|
88
119
|
// Vite uses vite-plugin-cedar-remove-dev-fatal-error-page
|
|
89
|
-
!forVite && [
|
|
90
|
-
"babel-plugin-graphql-tag",
|
|
91
|
-
void 0,
|
|
92
|
-
"rwjs-babel-graphql-tag"
|
|
93
|
-
],
|
|
94
120
|
forJest && process.env.NODE_ENV !== "development" && [
|
|
95
|
-
|
|
121
|
+
require("./plugins/babel-plugin-redwood-remove-dev-fatal-error-page").default,
|
|
96
122
|
void 0,
|
|
97
123
|
"rwjs-remove-dev-fatal-error-page"
|
|
98
124
|
]
|
|
@@ -108,7 +134,7 @@ const getWebSideOverrides = ({ forPrerender, forVite } = { forPrerender: false }
|
|
|
108
134
|
test: /src[\/\\]Routes.(js|tsx|jsx)$/,
|
|
109
135
|
plugins: [
|
|
110
136
|
[
|
|
111
|
-
|
|
137
|
+
require("./plugins/babel-plugin-redwood-routes-auto-loader").default,
|
|
112
138
|
// The plugin will modify the Routes file differently based on what
|
|
113
139
|
// context we're building for
|
|
114
140
|
{
|
|
@@ -121,14 +147,10 @@ const getWebSideOverrides = ({ forPrerender, forVite } = { forPrerender: false }
|
|
|
121
147
|
// ** Files ending in `Cell.mock.[js,ts]` **
|
|
122
148
|
// Automatically determine keys for saving and retrieving mock data.
|
|
123
149
|
// Only required for storybook and jest
|
|
124
|
-
|
|
125
|
-
// (vite-plugin-cedar-mock-cell-data). Jest (CJS projects) still needs the
|
|
126
|
-
// Babel plugin because it doesn't go through Vite's pipeline, so we keep
|
|
127
|
-
// the override active for non-Vite contexts.
|
|
128
|
-
!forVite && process.env.NODE_ENV !== "production" && {
|
|
150
|
+
process.env.NODE_ENV !== "production" && {
|
|
129
151
|
test: /.+Cell.mock.(js|ts)$/,
|
|
130
152
|
plugins: [
|
|
131
|
-
|
|
153
|
+
require("./plugins/babel-plugin-redwood-mock-cell-data").default
|
|
132
154
|
]
|
|
133
155
|
}
|
|
134
156
|
];
|
|
@@ -142,7 +164,7 @@ const getWebSideBabelPresets = (options) => {
|
|
|
142
164
|
if (options.forPrerender || options.forJest || options.forJavaScriptLinting) {
|
|
143
165
|
let reactPresetConfig = { runtime: "automatic" };
|
|
144
166
|
if (getWebSideBabelConfigPath()) {
|
|
145
|
-
const userProjectConfig =
|
|
167
|
+
const userProjectConfig = require(getWebSideBabelConfigPath());
|
|
146
168
|
userProjectConfig.presets?.forEach(
|
|
147
169
|
(preset) => {
|
|
148
170
|
if (!Array.isArray(preset)) {
|
|
@@ -171,8 +193,8 @@ const getWebSideBabelPresets = (options) => {
|
|
|
171
193
|
return [];
|
|
172
194
|
};
|
|
173
195
|
const getWebSideBabelConfigPath = () => {
|
|
174
|
-
const customBabelConfig =
|
|
175
|
-
if (
|
|
196
|
+
const customBabelConfig = import_node_path.default.join((0, import_project_config.getPaths)().web.base, "babel.config.js");
|
|
197
|
+
if (import_node_fs.default.existsSync(customBabelConfig)) {
|
|
176
198
|
return customBabelConfig;
|
|
177
199
|
} else {
|
|
178
200
|
return void 0;
|
|
@@ -194,9 +216,9 @@ const registerWebSideBabelHook = ({
|
|
|
194
216
|
options = {}
|
|
195
217
|
} = {}) => {
|
|
196
218
|
const defaultOptions = getWebSideDefaultBabelConfig(options);
|
|
197
|
-
registerBabel({
|
|
219
|
+
(0, import_common.registerBabel)({
|
|
198
220
|
...defaultOptions,
|
|
199
|
-
root: getPaths().base,
|
|
221
|
+
root: (0, import_project_config.getPaths)().base,
|
|
200
222
|
extensions: [".js", ".ts", ".tsx", ".jsx"],
|
|
201
223
|
plugins: [...defaultOptions.plugins, ...plugins],
|
|
202
224
|
cache: false,
|
|
@@ -205,11 +227,12 @@ const registerWebSideBabelHook = ({
|
|
|
205
227
|
overrides: [...getWebSideOverrides({ forPrerender: true }), ...overrides]
|
|
206
228
|
});
|
|
207
229
|
};
|
|
208
|
-
export
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
209
232
|
getWebSideBabelConfigPath,
|
|
210
233
|
getWebSideBabelPlugins,
|
|
211
234
|
getWebSideBabelPresets,
|
|
212
235
|
getWebSideDefaultBabelConfig,
|
|
213
236
|
getWebSideOverrides,
|
|
214
237
|
registerWebSideBabelHook
|
|
215
|
-
};
|
|
238
|
+
});
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/babel-config",
|
|
3
|
-
"version": "5.0.4
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
7
7
|
"directory": "packages/babel-config"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"type": "
|
|
10
|
+
"type": "commonjs",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./dist/index.js",
|
|
13
13
|
"./dist/plugins/*": "./dist/plugins/*"
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "node ./build.mts",
|
|
20
|
+
"build": "node ./build.mts && run build:types",
|
|
21
21
|
"build:pack": "yarn pack -o cedarjs-babel-config.tgz",
|
|
22
|
-
"build:types": "tsc --build --verbose
|
|
22
|
+
"build:types": "tsc --build --verbose",
|
|
23
23
|
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
24
24
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
25
25
|
"test": "vitest run",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@babel/preset-typescript": "7.29.7",
|
|
36
36
|
"@babel/register": "7.29.7",
|
|
37
37
|
"@babel/traverse": "7.29.7",
|
|
38
|
-
"@cedarjs/project-config": "5.0.4
|
|
38
|
+
"@cedarjs/project-config": "5.0.4",
|
|
39
39
|
"babel-plugin-auto-import": "1.1.0",
|
|
40
40
|
"babel-plugin-graphql-tag": "3.3.0",
|
|
41
41
|
"babel-plugin-module-resolver": "5.0.3",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"typescript": "5.9.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@cedarjs/framework-tools": "5.0.4
|
|
47
|
+
"@cedarjs/framework-tools": "5.0.4",
|
|
48
48
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
49
49
|
"@types/babel-plugin-tester": "11.0.0",
|
|
50
50
|
"@types/babel__core": "7.20.5",
|
|
51
51
|
"@types/babel__register": "7.17.3",
|
|
52
52
|
"@types/node": "24.10.4",
|
|
53
53
|
"babel-plugin-tester": "11.0.4",
|
|
54
|
-
"vitest": "
|
|
54
|
+
"vitest": "3.2.6"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=24"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-handler-als-wrapping.d.ts","sourceRoot":"","sources":["../../src/plugins/babel-plugin-handler-als-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"}
|