@cedarjs/vite 0.1.1-next.0 → 0.1.2-next.95
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/build/build.d.ts.map +1 -1
- package/dist/build/build.js +3 -3
- package/dist/cjs/build/build.js +3 -3
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/plugins/vite-plugin-cedar-cell.js +183 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/plugins/vite-plugin-cedar-cell.d.ts +23 -0
- package/dist/plugins/vite-plugin-cedar-cell.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-cell.js +149 -0
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AAIpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAIlD,eAAO,MAAM,aAAa,YAIzB,CAAA;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,KAAU,yCAUvE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,mBAS9C;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAoB,MAAM,EAAE,UAAU,KAAK,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AAIpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAIlD,eAAO,MAAM,aAAa,YAIzB,CAAA;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,KAAU,yCAUvE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,mBAS9C;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,aAAoB,MAAM,EAAE,UAAU,KAAK,oCAgCvE,CAAA;AAED,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,gBAAuB,YAAY,8GAoBvD,CAAA"}
|
package/dist/build/build.js
CHANGED
|
@@ -11,7 +11,7 @@ const cleanWebBuild = () => {
|
|
|
11
11
|
fse.removeSync(path.join(rwjsPaths.generated.prebuild, "web"));
|
|
12
12
|
};
|
|
13
13
|
async function prebuildWebFile(srcPath, flags = {}) {
|
|
14
|
-
const code = fs.
|
|
14
|
+
const code = await fs.promises.readFile(srcPath, "utf-8");
|
|
15
15
|
const config = getWebSideDefaultBabelConfig(flags);
|
|
16
16
|
const result = babel.transform(code, {
|
|
17
17
|
...config,
|
|
@@ -38,8 +38,8 @@ const prebuildWebFiles = async (srcFiles, flags) => {
|
|
|
38
38
|
if (!result?.code) {
|
|
39
39
|
throw new Error("No code returned from prebuildWebFile");
|
|
40
40
|
}
|
|
41
|
-
fs.
|
|
42
|
-
fs.
|
|
41
|
+
await fs.promises.mkdir(path.dirname(dstPath), { recursive: true });
|
|
42
|
+
await fs.promises.writeFile(dstPath, result.code);
|
|
43
43
|
} catch {
|
|
44
44
|
console.warn("Error:", srcPath, "could not prebuilt.");
|
|
45
45
|
return void 0;
|
package/dist/cjs/build/build.js
CHANGED
|
@@ -48,7 +48,7 @@ const cleanWebBuild = () => {
|
|
|
48
48
|
import_fs_extra.default.removeSync(import_node_path.default.join(rwjsPaths.generated.prebuild, "web"));
|
|
49
49
|
};
|
|
50
50
|
async function prebuildWebFile(srcPath, flags = {}) {
|
|
51
|
-
const code = import_node_fs.default.
|
|
51
|
+
const code = await import_node_fs.default.promises.readFile(srcPath, "utf-8");
|
|
52
52
|
const config = (0, import_babel_config.getWebSideDefaultBabelConfig)(flags);
|
|
53
53
|
const result = babel.transform(code, {
|
|
54
54
|
...config,
|
|
@@ -75,8 +75,8 @@ const prebuildWebFiles = async (srcFiles, flags) => {
|
|
|
75
75
|
if (!result?.code) {
|
|
76
76
|
throw new Error("No code returned from prebuildWebFile");
|
|
77
77
|
}
|
|
78
|
-
import_node_fs.default.
|
|
79
|
-
import_node_fs.default.
|
|
78
|
+
await import_node_fs.default.promises.mkdir(import_node_path.default.dirname(dstPath), { recursive: true });
|
|
79
|
+
await import_node_fs.default.promises.writeFile(dstPath, result.code);
|
|
80
80
|
} catch {
|
|
81
81
|
console.warn("Error:", srcPath, "could not prebuilt.");
|
|
82
82
|
return void 0;
|
package/dist/cjs/index.js
CHANGED
|
@@ -39,6 +39,7 @@ var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
|
|
|
39
39
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
40
40
|
var import_project_config = require("@cedarjs/project-config");
|
|
41
41
|
var import_getMergedConfig = require("./lib/getMergedConfig.js");
|
|
42
|
+
var import_vite_plugin_cedar_cell = require("./plugins/vite-plugin-cedar-cell.js");
|
|
42
43
|
var import_vite_plugin_jsx_loader = require("./plugins/vite-plugin-jsx-loader.js");
|
|
43
44
|
var import_vite_plugin_remove_from_bundle = require("./plugins/vite-plugin-remove-from-bundle.js");
|
|
44
45
|
var import_vite_plugin_swap_apollo_provider = require("./plugins/vite-plugin-swap-apollo-provider.js");
|
|
@@ -162,6 +163,8 @@ function redwoodPluginVite() {
|
|
|
162
163
|
},
|
|
163
164
|
// We can remove when streaming is stable
|
|
164
165
|
streamingEnabled && (0, import_vite_plugin_swap_apollo_provider.swapApolloProvider)(),
|
|
166
|
+
// Transform files ending with 'Cell' to wrap them in createCell HOC
|
|
167
|
+
(0, import_vite_plugin_cedar_cell.cedarCellTransform)(),
|
|
165
168
|
(0, import_vite_plugin_jsx_loader.handleJsAsJsx)(),
|
|
166
169
|
// Remove the splash-page from the bundle.
|
|
167
170
|
(0, import_vite_plugin_remove_from_bundle.removeFromBundle)(
|
|
@@ -0,0 +1,183 @@
|
|
|
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 vite_plugin_cedar_cell_exports = {};
|
|
30
|
+
__export(vite_plugin_cedar_cell_exports, {
|
|
31
|
+
cedarCellTransform: () => cedarCellTransform
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_cedar_cell_exports);
|
|
34
|
+
var import_node_path = require("node:path");
|
|
35
|
+
var import_generator = __toESM(require("@babel/generator"), 1);
|
|
36
|
+
var import_parser = require("@babel/parser");
|
|
37
|
+
var import_traverse = __toESM(require("@babel/traverse"), 1);
|
|
38
|
+
const traverse = import_traverse.default.default;
|
|
39
|
+
const generate = import_generator.default.default;
|
|
40
|
+
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
41
|
+
"beforeQuery",
|
|
42
|
+
"QUERY",
|
|
43
|
+
"data",
|
|
44
|
+
"isEmpty",
|
|
45
|
+
"afterQuery",
|
|
46
|
+
"Loading",
|
|
47
|
+
"Success",
|
|
48
|
+
"Failure",
|
|
49
|
+
"Empty"
|
|
50
|
+
];
|
|
51
|
+
function cedarCellTransform() {
|
|
52
|
+
return {
|
|
53
|
+
name: "vite-plugin-cedar-cell",
|
|
54
|
+
transform(code, id) {
|
|
55
|
+
if (!id.match(/Cell\.[jt]sx?$/)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const ast = (0, import_parser.parse)(code, {
|
|
60
|
+
sourceType: "module",
|
|
61
|
+
plugins: [
|
|
62
|
+
"jsx",
|
|
63
|
+
"typescript",
|
|
64
|
+
"decorators-legacy",
|
|
65
|
+
"classProperties",
|
|
66
|
+
"objectRestSpread",
|
|
67
|
+
"asyncGenerators",
|
|
68
|
+
"functionBind",
|
|
69
|
+
"exportDefaultFrom",
|
|
70
|
+
"exportNamespaceFrom",
|
|
71
|
+
"dynamicImport",
|
|
72
|
+
"nullishCoalescingOperator",
|
|
73
|
+
"optionalChaining"
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
const exportNames = [];
|
|
77
|
+
let hasDefaultExport = false;
|
|
78
|
+
traverse(ast, {
|
|
79
|
+
ExportDefaultDeclaration() {
|
|
80
|
+
hasDefaultExport = true;
|
|
81
|
+
},
|
|
82
|
+
ExportNamedDeclaration(path) {
|
|
83
|
+
const declaration = path.node.declaration;
|
|
84
|
+
if (!declaration) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let name;
|
|
88
|
+
if (declaration.type === "VariableDeclaration") {
|
|
89
|
+
const id2 = declaration.declarations[0].id;
|
|
90
|
+
name = id2.name;
|
|
91
|
+
}
|
|
92
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
93
|
+
name = declaration?.id?.name;
|
|
94
|
+
}
|
|
95
|
+
if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
|
|
96
|
+
exportNames.push(name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
|
|
101
|
+
if (hasDefaultExport || !hasQueryOrDataExport) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
|
|
105
|
+
const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
|
|
106
|
+
traverse(ast, {
|
|
107
|
+
Program(path) {
|
|
108
|
+
const importDeclaration = {
|
|
109
|
+
type: "ImportDeclaration",
|
|
110
|
+
specifiers: [
|
|
111
|
+
{
|
|
112
|
+
type: "ImportSpecifier",
|
|
113
|
+
imported: {
|
|
114
|
+
type: "Identifier",
|
|
115
|
+
name: createCellHookName
|
|
116
|
+
},
|
|
117
|
+
local: {
|
|
118
|
+
type: "Identifier",
|
|
119
|
+
name: createCellHookName
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
source: { type: "StringLiteral", value: importFrom }
|
|
124
|
+
};
|
|
125
|
+
path.node.body.unshift(importDeclaration);
|
|
126
|
+
const objectProperties = [
|
|
127
|
+
...exportNames.map((name) => ({
|
|
128
|
+
type: "ObjectProperty",
|
|
129
|
+
key: { type: "Identifier", name },
|
|
130
|
+
value: { type: "Identifier", name },
|
|
131
|
+
shorthand: true,
|
|
132
|
+
computed: false
|
|
133
|
+
})),
|
|
134
|
+
// Add the displayName property
|
|
135
|
+
{
|
|
136
|
+
type: "ObjectProperty",
|
|
137
|
+
key: { type: "Identifier", name: "displayName" },
|
|
138
|
+
value: {
|
|
139
|
+
type: "StringLiteral",
|
|
140
|
+
value: (0, import_node_path.parse)(id).name
|
|
141
|
+
},
|
|
142
|
+
shorthand: false,
|
|
143
|
+
computed: false
|
|
144
|
+
}
|
|
145
|
+
];
|
|
146
|
+
const exportDefaultDeclaration = {
|
|
147
|
+
type: "ExportDefaultDeclaration",
|
|
148
|
+
declaration: {
|
|
149
|
+
type: "CallExpression",
|
|
150
|
+
callee: {
|
|
151
|
+
type: "Identifier",
|
|
152
|
+
name: createCellHookName
|
|
153
|
+
},
|
|
154
|
+
arguments: [
|
|
155
|
+
{
|
|
156
|
+
type: "ObjectExpression",
|
|
157
|
+
properties: objectProperties
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
path.node.body.push(exportDefaultDeclaration);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
const result = generate(ast, {
|
|
166
|
+
retainLines: true,
|
|
167
|
+
compact: false
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
code: result.code,
|
|
171
|
+
map: result.map
|
|
172
|
+
};
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.warn(`Failed to transform Cell file ${id}:`, error);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
cedarCellTransform
|
|
183
|
+
});
|
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,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAaxC;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,YAAY,EAAE,CA0K1D"}
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
|
6
6
|
import { getWebSideDefaultBabelConfig } from "@cedarjs/babel-config";
|
|
7
7
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
8
8
|
import { getMergedConfig } from "./lib/getMergedConfig.js";
|
|
9
|
+
import { cedarCellTransform } from "./plugins/vite-plugin-cedar-cell.js";
|
|
9
10
|
import { handleJsAsJsx } from "./plugins/vite-plugin-jsx-loader.js";
|
|
10
11
|
import { removeFromBundle } from "./plugins/vite-plugin-remove-from-bundle.js";
|
|
11
12
|
import { swapApolloProvider } from "./plugins/vite-plugin-swap-apollo-provider.js";
|
|
@@ -129,6 +130,8 @@ function redwoodPluginVite() {
|
|
|
129
130
|
},
|
|
130
131
|
// We can remove when streaming is stable
|
|
131
132
|
streamingEnabled && swapApolloProvider(),
|
|
133
|
+
// Transform files ending with 'Cell' to wrap them in createCell HOC
|
|
134
|
+
cedarCellTransform(),
|
|
132
135
|
handleJsAsJsx(),
|
|
133
136
|
// Remove the splash-page from the bundle.
|
|
134
137
|
removeFromBundle(
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin that wraps files with a suffix of `Cell` in Redwood's `createCell`
|
|
4
|
+
* higher order component. The HOC deals with the lifecycle methods during a GraphQL query.
|
|
5
|
+
*
|
|
6
|
+
* This transforms:
|
|
7
|
+
* ```js
|
|
8
|
+
* export const QUERY = gql`...`
|
|
9
|
+
* export const Loading = () => <div>Loading...</div>
|
|
10
|
+
* export const Success = ({ data }) => <div>{data}</div>
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Into:
|
|
14
|
+
* ```js
|
|
15
|
+
* import { createCell } from '@cedarjs/web'
|
|
16
|
+
* export const QUERY = gql`...`
|
|
17
|
+
* export const Loading = () => <div>Loading...</div>
|
|
18
|
+
* export const Success = ({ data }) => <div>{data}</div>
|
|
19
|
+
* export default createCell({ QUERY, Loading, Success, displayName: 'MyCell' })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function cedarCellTransform(): Plugin;
|
|
23
|
+
//# sourceMappingURL=vite-plugin-cedar-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-cell.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-cell.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAiBlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAmK3C"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { parse as parsePath } from "node:path";
|
|
2
|
+
import babelGenerator from "@babel/generator";
|
|
3
|
+
import { parse } from "@babel/parser";
|
|
4
|
+
import babelTraverse from "@babel/traverse";
|
|
5
|
+
const traverse = babelTraverse.default;
|
|
6
|
+
const generate = babelGenerator.default;
|
|
7
|
+
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
8
|
+
"beforeQuery",
|
|
9
|
+
"QUERY",
|
|
10
|
+
"data",
|
|
11
|
+
"isEmpty",
|
|
12
|
+
"afterQuery",
|
|
13
|
+
"Loading",
|
|
14
|
+
"Success",
|
|
15
|
+
"Failure",
|
|
16
|
+
"Empty"
|
|
17
|
+
];
|
|
18
|
+
function cedarCellTransform() {
|
|
19
|
+
return {
|
|
20
|
+
name: "vite-plugin-cedar-cell",
|
|
21
|
+
transform(code, id) {
|
|
22
|
+
if (!id.match(/Cell\.[jt]sx?$/)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const ast = parse(code, {
|
|
27
|
+
sourceType: "module",
|
|
28
|
+
plugins: [
|
|
29
|
+
"jsx",
|
|
30
|
+
"typescript",
|
|
31
|
+
"decorators-legacy",
|
|
32
|
+
"classProperties",
|
|
33
|
+
"objectRestSpread",
|
|
34
|
+
"asyncGenerators",
|
|
35
|
+
"functionBind",
|
|
36
|
+
"exportDefaultFrom",
|
|
37
|
+
"exportNamespaceFrom",
|
|
38
|
+
"dynamicImport",
|
|
39
|
+
"nullishCoalescingOperator",
|
|
40
|
+
"optionalChaining"
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
const exportNames = [];
|
|
44
|
+
let hasDefaultExport = false;
|
|
45
|
+
traverse(ast, {
|
|
46
|
+
ExportDefaultDeclaration() {
|
|
47
|
+
hasDefaultExport = true;
|
|
48
|
+
},
|
|
49
|
+
ExportNamedDeclaration(path) {
|
|
50
|
+
const declaration = path.node.declaration;
|
|
51
|
+
if (!declaration) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let name;
|
|
55
|
+
if (declaration.type === "VariableDeclaration") {
|
|
56
|
+
const id2 = declaration.declarations[0].id;
|
|
57
|
+
name = id2.name;
|
|
58
|
+
}
|
|
59
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
60
|
+
name = declaration?.id?.name;
|
|
61
|
+
}
|
|
62
|
+
if (name && EXPECTED_EXPORTS_FROM_CELL.includes(name)) {
|
|
63
|
+
exportNames.push(name);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const hasQueryOrDataExport = exportNames.includes("QUERY") || exportNames.includes("data");
|
|
68
|
+
if (hasDefaultExport || !hasQueryOrDataExport) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const createCellHookName = exportNames.includes("data") ? "createServerCell" : "createCell";
|
|
72
|
+
const importFrom = exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
|
|
73
|
+
traverse(ast, {
|
|
74
|
+
Program(path) {
|
|
75
|
+
const importDeclaration = {
|
|
76
|
+
type: "ImportDeclaration",
|
|
77
|
+
specifiers: [
|
|
78
|
+
{
|
|
79
|
+
type: "ImportSpecifier",
|
|
80
|
+
imported: {
|
|
81
|
+
type: "Identifier",
|
|
82
|
+
name: createCellHookName
|
|
83
|
+
},
|
|
84
|
+
local: {
|
|
85
|
+
type: "Identifier",
|
|
86
|
+
name: createCellHookName
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
source: { type: "StringLiteral", value: importFrom }
|
|
91
|
+
};
|
|
92
|
+
path.node.body.unshift(importDeclaration);
|
|
93
|
+
const objectProperties = [
|
|
94
|
+
...exportNames.map((name) => ({
|
|
95
|
+
type: "ObjectProperty",
|
|
96
|
+
key: { type: "Identifier", name },
|
|
97
|
+
value: { type: "Identifier", name },
|
|
98
|
+
shorthand: true,
|
|
99
|
+
computed: false
|
|
100
|
+
})),
|
|
101
|
+
// Add the displayName property
|
|
102
|
+
{
|
|
103
|
+
type: "ObjectProperty",
|
|
104
|
+
key: { type: "Identifier", name: "displayName" },
|
|
105
|
+
value: {
|
|
106
|
+
type: "StringLiteral",
|
|
107
|
+
value: parsePath(id).name
|
|
108
|
+
},
|
|
109
|
+
shorthand: false,
|
|
110
|
+
computed: false
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
const exportDefaultDeclaration = {
|
|
114
|
+
type: "ExportDefaultDeclaration",
|
|
115
|
+
declaration: {
|
|
116
|
+
type: "CallExpression",
|
|
117
|
+
callee: {
|
|
118
|
+
type: "Identifier",
|
|
119
|
+
name: createCellHookName
|
|
120
|
+
},
|
|
121
|
+
arguments: [
|
|
122
|
+
{
|
|
123
|
+
type: "ObjectExpression",
|
|
124
|
+
properties: objectProperties
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
path.node.body.push(exportDefaultDeclaration);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const result = generate(ast, {
|
|
133
|
+
retainLines: true,
|
|
134
|
+
compact: false
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
code: result.code,
|
|
138
|
+
map: result.map
|
|
139
|
+
};
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.warn(`Failed to transform Cell file ${id}:`, error);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
cedarCellTransform
|
|
149
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-next.95+a711c9cda",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,17 +56,17 @@
|
|
|
56
56
|
"test:watch": "vitest watch"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@babel/generator": "7.27.
|
|
60
|
-
"@babel/parser": "7.27.
|
|
61
|
-
"@babel/traverse": "7.27.
|
|
62
|
-
"@cedarjs/auth": "0.1.
|
|
63
|
-
"@cedarjs/babel-config": "0.1.
|
|
64
|
-
"@cedarjs/cookie-jar": "0.1.
|
|
65
|
-
"@cedarjs/internal": "0.1.
|
|
66
|
-
"@cedarjs/project-config": "0.1.
|
|
67
|
-
"@cedarjs/server-store": "0.1.
|
|
68
|
-
"@cedarjs/web": "0.1.
|
|
69
|
-
"@swc/core": "1.
|
|
59
|
+
"@babel/generator": "7.27.5",
|
|
60
|
+
"@babel/parser": "7.27.5",
|
|
61
|
+
"@babel/traverse": "7.27.4",
|
|
62
|
+
"@cedarjs/auth": "0.1.2-next.95+a711c9cda",
|
|
63
|
+
"@cedarjs/babel-config": "0.1.2-next.95+a711c9cda",
|
|
64
|
+
"@cedarjs/cookie-jar": "0.1.2-next.95+a711c9cda",
|
|
65
|
+
"@cedarjs/internal": "0.1.2-next.95+a711c9cda",
|
|
66
|
+
"@cedarjs/project-config": "0.1.2-next.95+a711c9cda",
|
|
67
|
+
"@cedarjs/server-store": "0.1.2-next.95+a711c9cda",
|
|
68
|
+
"@cedarjs/web": "0.1.2-next.95+a711c9cda",
|
|
69
|
+
"@swc/core": "1.12.1",
|
|
70
70
|
"@vitejs/plugin-react": "4.3.4",
|
|
71
71
|
"@whatwg-node/fetch": "0.9.21",
|
|
72
72
|
"@whatwg-node/server": "0.9.65",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"find-my-way": "8.2.2",
|
|
82
82
|
"fs-extra": "11.2.0",
|
|
83
83
|
"http-proxy-middleware": "3.0.5",
|
|
84
|
-
"isbot": "5.1.
|
|
84
|
+
"isbot": "5.1.28",
|
|
85
85
|
"react": "18.3.1",
|
|
86
86
|
"react-server-dom-webpack": "19.0.0-rc-8269d55d-20240802",
|
|
87
87
|
"rimraf": "6.0.1",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"yargs-parser": "21.1.1"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@arethetypeswrong/cli": "0.
|
|
96
|
-
"@hyrious/esbuild-plugin-commonjs": "0.2.
|
|
95
|
+
"@arethetypeswrong/cli": "0.18.1",
|
|
96
|
+
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
97
97
|
"@types/busboy": "^1",
|
|
98
98
|
"@types/express": "4",
|
|
99
99
|
"@types/fs-extra": "11.0.4",
|
|
@@ -102,15 +102,15 @@
|
|
|
102
102
|
"@types/yargs-parser": "21.0.3",
|
|
103
103
|
"concurrently": "8.2.2",
|
|
104
104
|
"glob": "11.0.0",
|
|
105
|
-
"memfs": "4.17.
|
|
106
|
-
"publint": "0.3.
|
|
105
|
+
"memfs": "4.17.2",
|
|
106
|
+
"publint": "0.3.12",
|
|
107
107
|
"rollup": "4.24.0",
|
|
108
|
-
"tsx": "4.19.
|
|
108
|
+
"tsx": "4.19.4",
|
|
109
109
|
"typescript": "5.6.2",
|
|
110
|
-
"vitest": "2.
|
|
110
|
+
"vitest": "3.2.4"
|
|
111
111
|
},
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "a711c9cda09da9444fb0f6ff5d9dae804d6ba72b"
|
|
116
116
|
}
|