@cedarjs/vite 6.0.0-canary.2633 → 6.0.0-canary.2636
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/apiDevMiddleware.d.ts.map +1 -1
- package/dist/apiDevMiddleware.js +2 -1
- package/dist/cjs/apiDevMiddleware.js +2 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/plugins/vite-plugin-cedar-directory-named-import.js +69 -0
- package/dist/cjs/plugins/vite-plugin-cedar-graphql-options-extract.js +22 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts +12 -0
- package/dist/plugins/vite-plugin-cedar-directory-named-import.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-directory-named-import.js +35 -0
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts +7 -3
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-cedar-graphql-options-extract.js +12 -7
- package/package.json +14 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAA;AAgC7D,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA+GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"apiDevMiddleware.d.ts","sourceRoot":"","sources":["../src/apiDevMiddleware.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAA;AAgC7D,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,aAAa,iBAe/D;AA+GD,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,CAAC,CA8GlE;AA0BD,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CA0EhE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,KAIrB,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAoFnD;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC;IACrD,UAAU,EAAE,aAAa,CAAA;IACzB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CACjD,CAAC,CAcD"}
|
package/dist/apiDevMiddleware.js
CHANGED
|
@@ -167,7 +167,8 @@ async function createApiViteServer() {
|
|
|
167
167
|
try {
|
|
168
168
|
let sourceCode = code;
|
|
169
169
|
if (normalizePath(id).endsWith("/graphql.ts") || normalizePath(id).endsWith("/graphql.js")) {
|
|
170
|
-
|
|
170
|
+
const extracted = applyGraphqlOptionsExtract(sourceCode);
|
|
171
|
+
sourceCode = extracted?.code ?? sourceCode;
|
|
171
172
|
sourceCode = applyGqlormInject(sourceCode, id) ?? sourceCode;
|
|
172
173
|
}
|
|
173
174
|
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
|
@@ -201,7 +201,8 @@ async function createApiViteServer() {
|
|
|
201
201
|
try {
|
|
202
202
|
let sourceCode = code;
|
|
203
203
|
if ((0, import_vite.normalizePath)(id).endsWith("/graphql.ts") || (0, import_vite.normalizePath)(id).endsWith("/graphql.js")) {
|
|
204
|
-
|
|
204
|
+
const extracted = (0, import_vite_plugin_cedar_graphql_options_extract.applyGraphqlOptionsExtract)(sourceCode);
|
|
205
|
+
sourceCode = extracted?.code ?? sourceCode;
|
|
205
206
|
sourceCode = (0, import_api_graphql_transforms.applyGqlormInject)(sourceCode, id) ?? sourceCode;
|
|
206
207
|
}
|
|
207
208
|
if (cedarConfig.experimental?.opentelemetry?.enabled && cedarConfig.experimental?.opentelemetry?.wrapApi) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
cedarCellTransform: () => import_vite_plugin_cedar_cell2.cedarCellTransform,
|
|
35
35
|
cedarCjsCompatPlugin: () => import_vite_plugin_cedar_cjs_compat.cedarCjsCompatPlugin,
|
|
36
36
|
cedarDataUriShim: () => import_vite_plugin_cedar_data_uri_shim2.cedarDataUriShim,
|
|
37
|
+
cedarDirectoryNamedImportPlugin: () => import_vite_plugin_cedar_directory_named_import.cedarDirectoryNamedImportPlugin,
|
|
37
38
|
cedarEntryInjectionPlugin: () => import_vite_plugin_cedar_entry_injection2.cedarEntryInjectionPlugin,
|
|
38
39
|
cedarGqlormInjectPlugin: () => import_vite_plugin_cedar_gqlorm_inject.cedarGqlormInjectPlugin,
|
|
39
40
|
cedarGraphqlOptionsExtractPlugin: () => import_vite_plugin_cedar_graphql_options_extract.cedarGraphqlOptionsExtractPlugin,
|
|
@@ -84,6 +85,7 @@ var import_vite_plugin_cedar_otel_wrapping = require("./plugins/vite-plugin-ceda
|
|
|
84
85
|
var import_vite_plugin_handler_als_wrapping = require("./plugins/vite-plugin-handler-als-wrapping.js");
|
|
85
86
|
var import_vite_plugin_cedar_entry_injection2 = require("./plugins/vite-plugin-cedar-entry-injection.js");
|
|
86
87
|
var import_vite_plugin_cedar_html_env2 = require("./plugins/vite-plugin-cedar-html-env.js");
|
|
88
|
+
var import_vite_plugin_cedar_directory_named_import = require("./plugins/vite-plugin-cedar-directory-named-import.js");
|
|
87
89
|
var import_vite_plugin_cedar_import_dir = require("./plugins/vite-plugin-cedar-import-dir.js");
|
|
88
90
|
var import_vite_plugin_cedar_data_uri_shim2 = require("./plugins/vite-plugin-cedar-data-uri-shim.js");
|
|
89
91
|
var import_vite_plugin_cedar_remove_dev_fatal_error_page2 = require("./plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js");
|
|
@@ -144,6 +146,7 @@ var index_default = cedar;
|
|
|
144
146
|
cedarCellTransform,
|
|
145
147
|
cedarCjsCompatPlugin,
|
|
146
148
|
cedarDataUriShim,
|
|
149
|
+
cedarDirectoryNamedImportPlugin,
|
|
147
150
|
cedarEntryInjectionPlugin,
|
|
148
151
|
cedarGqlormInjectPlugin,
|
|
149
152
|
cedarGraphqlOptionsExtractPlugin,
|
|
@@ -0,0 +1,69 @@
|
|
|
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_directory_named_import_exports = {};
|
|
30
|
+
__export(vite_plugin_cedar_directory_named_import_exports, {
|
|
31
|
+
cedarDirectoryNamedImportPlugin: () => cedarDirectoryNamedImportPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_cedar_directory_named_import_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_vite = require("vite");
|
|
36
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
+
function cedarDirectoryNamedImportPlugin() {
|
|
38
|
+
return {
|
|
39
|
+
name: "vite-plugin-cedar-directory-named-import",
|
|
40
|
+
resolveId(id, importer) {
|
|
41
|
+
if (!id.startsWith(".") || !importer) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if ((0, import_vite.normalizePath)(importer).includes("/node_modules/")) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const absolutePath = import_node_path.default.resolve(import_node_path.default.dirname(importer), id);
|
|
48
|
+
if ((0, import_project_config.resolveFile)(absolutePath)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const basename = import_node_path.default.basename(absolutePath);
|
|
52
|
+
const indexPath = absolutePath + "/index";
|
|
53
|
+
const resolvedIndex = (0, import_project_config.resolveFile)(indexPath);
|
|
54
|
+
if (resolvedIndex) {
|
|
55
|
+
return (0, import_vite.normalizePath)(resolvedIndex);
|
|
56
|
+
}
|
|
57
|
+
const dirnamedPath = absolutePath + "/" + basename;
|
|
58
|
+
const resolvedDirnamed = (0, import_project_config.resolveFile)(dirnamedPath);
|
|
59
|
+
if (resolvedDirnamed) {
|
|
60
|
+
return (0, import_vite.normalizePath)(resolvedDirnamed);
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
cedarDirectoryNamedImportPlugin
|
|
69
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var vite_plugin_cedar_graphql_options_extract_exports = {};
|
|
20
30
|
__export(vite_plugin_cedar_graphql_options_extract_exports, {
|
|
@@ -22,6 +32,7 @@ __export(vite_plugin_cedar_graphql_options_extract_exports, {
|
|
|
22
32
|
cedarGraphqlOptionsExtractPlugin: () => cedarGraphqlOptionsExtractPlugin
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(vite_plugin_cedar_graphql_options_extract_exports);
|
|
35
|
+
var import_magic_string = __toESM(require("magic-string"), 1);
|
|
25
36
|
var import_oxc_parser = require("oxc-parser");
|
|
26
37
|
function cedarGraphqlOptionsExtractPlugin() {
|
|
27
38
|
return {
|
|
@@ -33,12 +44,13 @@ function cedarGraphqlOptionsExtractPlugin() {
|
|
|
33
44
|
if (!code.includes("createGraphQLHandler")) {
|
|
34
45
|
return null;
|
|
35
46
|
}
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
47
|
+
const result = applyGraphqlOptionsExtract(code);
|
|
48
|
+
if (!result) {
|
|
38
49
|
return null;
|
|
39
50
|
}
|
|
40
51
|
return {
|
|
41
|
-
code:
|
|
52
|
+
code: result.code,
|
|
53
|
+
map: result.map
|
|
42
54
|
};
|
|
43
55
|
}
|
|
44
56
|
};
|
|
@@ -101,10 +113,13 @@ function applyGraphqlOptionsExtract(code) {
|
|
|
101
113
|
optionsEnd
|
|
102
114
|
)}
|
|
103
115
|
`;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
116
|
+
const s = new import_magic_string.default(code);
|
|
117
|
+
s.prependLeft(lineStart, optionsConst);
|
|
118
|
+
s.overwrite(optionsStart, optionsEnd, "__cedar_graphqlOptions");
|
|
119
|
+
return {
|
|
120
|
+
code: s.toString(),
|
|
121
|
+
map: s.generateMap({ hires: true })
|
|
122
|
+
};
|
|
108
123
|
}
|
|
109
124
|
// Annotate the CommonJS export names for ESM import in node:
|
|
110
125
|
0 && (module.exports = {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { cedarOtelWrappingPlugin } from './plugins/vite-plugin-cedar-otel-wrappi
|
|
|
8
8
|
export { applyHandlerAlsWrapping, handlerAlsWrappingPlugin, } from './plugins/vite-plugin-handler-als-wrapping.js';
|
|
9
9
|
export { cedarEntryInjectionPlugin } from './plugins/vite-plugin-cedar-entry-injection.js';
|
|
10
10
|
export { cedarHtmlEnvPlugin } from './plugins/vite-plugin-cedar-html-env.js';
|
|
11
|
+
export { cedarDirectoryNamedImportPlugin } from './plugins/vite-plugin-cedar-directory-named-import.js';
|
|
11
12
|
export { cedarImportDirPlugin } from './plugins/vite-plugin-cedar-import-dir.js';
|
|
12
13
|
export { cedarDataUriShim } from './plugins/vite-plugin-cedar-data-uri-shim.js';
|
|
13
14
|
export { cedarRemoveDevFatalErrorPage } from './plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAoCxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAA;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAA;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,8DAA8D,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAE1F,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAoClE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAoCxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAA;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,+CAA+C,CAAA;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,+BAA+B,EAAE,MAAM,uDAAuD,CAAA;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAA;AAC/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAA;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAA;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,qCAAqC,EAAE,MAAM,8DAA8D,CAAA;AACpH,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iDAAiD,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAA;AAE1F,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAE,aAAkB,GAAG,YAAY,EAAE,CAoClE;AAED,8DAA8D;AAC9D,eAAe,KAAK,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from "./plugins/vite-plugin-handler-als-wrapping.js";
|
|
40
40
|
import { cedarEntryInjectionPlugin as cedarEntryInjectionPlugin2 } from "./plugins/vite-plugin-cedar-entry-injection.js";
|
|
41
41
|
import { cedarHtmlEnvPlugin as cedarHtmlEnvPlugin2 } from "./plugins/vite-plugin-cedar-html-env.js";
|
|
42
|
+
import { cedarDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedar-directory-named-import.js";
|
|
42
43
|
import { cedarImportDirPlugin } from "./plugins/vite-plugin-cedar-import-dir.js";
|
|
43
44
|
import { cedarDataUriShim as cedarDataUriShim2 } from "./plugins/vite-plugin-cedar-data-uri-shim.js";
|
|
44
45
|
import { cedarRemoveDevFatalErrorPage as cedarRemoveDevFatalErrorPage2 } from "./plugins/vite-plugin-cedar-remove-dev-fatal-error-page.js";
|
|
@@ -93,6 +94,7 @@ export {
|
|
|
93
94
|
cedarCellTransform2 as cedarCellTransform,
|
|
94
95
|
cedarCjsCompatPlugin,
|
|
95
96
|
cedarDataUriShim2 as cedarDataUriShim,
|
|
97
|
+
cedarDirectoryNamedImportPlugin,
|
|
96
98
|
cedarEntryInjectionPlugin2 as cedarEntryInjectionPlugin,
|
|
97
99
|
cedarGqlormInjectPlugin,
|
|
98
100
|
cedarGraphqlOptionsExtractPlugin,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves bare directory imports to the index file or directory-named module.
|
|
4
|
+
*
|
|
5
|
+
* When you import `./Button`, this plugin checks:
|
|
6
|
+
* 1. `./Button/index.[js|ts|tsx|jsx|...]` — preferred if it exists
|
|
7
|
+
* 2. `./Button/Button.[js|ts|tsx|jsx|...]` — directory-named module fallback
|
|
8
|
+
*
|
|
9
|
+
* This mirrors the behaviour of babel-plugin-redwood-directory-named-import.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cedarDirectoryNamedImportPlugin(): Plugin;
|
|
12
|
+
//# sourceMappingURL=vite-plugin-cedar-directory-named-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-directory-named-import.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-directory-named-import.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CA0CxD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { normalizePath } from "vite";
|
|
3
|
+
import { resolveFile } from "@cedarjs/project-config";
|
|
4
|
+
function cedarDirectoryNamedImportPlugin() {
|
|
5
|
+
return {
|
|
6
|
+
name: "vite-plugin-cedar-directory-named-import",
|
|
7
|
+
resolveId(id, importer) {
|
|
8
|
+
if (!id.startsWith(".") || !importer) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (normalizePath(importer).includes("/node_modules/")) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const absolutePath = path.resolve(path.dirname(importer), id);
|
|
15
|
+
if (resolveFile(absolutePath)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const basename = path.basename(absolutePath);
|
|
19
|
+
const indexPath = absolutePath + "/index";
|
|
20
|
+
const resolvedIndex = resolveFile(indexPath);
|
|
21
|
+
if (resolvedIndex) {
|
|
22
|
+
return normalizePath(resolvedIndex);
|
|
23
|
+
}
|
|
24
|
+
const dirnamedPath = absolutePath + "/" + basename;
|
|
25
|
+
const resolvedDirnamed = resolveFile(dirnamedPath);
|
|
26
|
+
if (resolvedDirnamed) {
|
|
27
|
+
return normalizePath(resolvedDirnamed);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
cedarDirectoryNamedImportPlugin
|
|
35
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SourceMap } from 'magic-string';
|
|
1
2
|
import type { Plugin } from 'vite';
|
|
2
3
|
/**
|
|
3
4
|
* Vite plugin that extracts options passed to createGraphQLHandler into an
|
|
@@ -21,8 +22,8 @@ import type { Plugin } from 'vite';
|
|
|
21
22
|
export declare function cedarGraphqlOptionsExtractPlugin(): Plugin;
|
|
22
23
|
/**
|
|
23
24
|
* Extracts the options argument from createGraphQLHandler calls and stores
|
|
24
|
-
* them in an exported variable. Returns the transformed code
|
|
25
|
-
* transformation was needed.
|
|
25
|
+
* them in an exported variable. Returns the transformed code with a sourcemap,
|
|
26
|
+
* or null if no transformation was needed.
|
|
26
27
|
*
|
|
27
28
|
* Transforms:
|
|
28
29
|
* export const handler = createGraphQLHandler({ options })
|
|
@@ -34,5 +35,8 @@ export declare function cedarGraphqlOptionsExtractPlugin(): Plugin;
|
|
|
34
35
|
* logic can run inside the Vite plugin pipeline without depending on internal's
|
|
35
36
|
* build output.
|
|
36
37
|
*/
|
|
37
|
-
export declare function applyGraphqlOptionsExtract(code: string):
|
|
38
|
+
export declare function applyGraphqlOptionsExtract(code: string): {
|
|
39
|
+
code: string;
|
|
40
|
+
map: SourceMap;
|
|
41
|
+
} | null;
|
|
38
42
|
//# sourceMappingURL=vite-plugin-cedar-graphql-options-extract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-graphql-options-extract.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-graphql-options-extract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,IAAI,MAAM,CA2BzD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,IAAI,CAgGzC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import MagicString from "magic-string";
|
|
1
2
|
import { parseSync, Visitor } from "oxc-parser";
|
|
2
3
|
function cedarGraphqlOptionsExtractPlugin() {
|
|
3
4
|
return {
|
|
@@ -9,12 +10,13 @@ function cedarGraphqlOptionsExtractPlugin() {
|
|
|
9
10
|
if (!code.includes("createGraphQLHandler")) {
|
|
10
11
|
return null;
|
|
11
12
|
}
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
13
|
+
const result = applyGraphqlOptionsExtract(code);
|
|
14
|
+
if (!result) {
|
|
14
15
|
return null;
|
|
15
16
|
}
|
|
16
17
|
return {
|
|
17
|
-
code:
|
|
18
|
+
code: result.code,
|
|
19
|
+
map: result.map
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
};
|
|
@@ -77,10 +79,13 @@ function applyGraphqlOptionsExtract(code) {
|
|
|
77
79
|
optionsEnd
|
|
78
80
|
)}
|
|
79
81
|
`;
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
82
|
+
const s = new MagicString(code);
|
|
83
|
+
s.prependLeft(lineStart, optionsConst);
|
|
84
|
+
s.overwrite(optionsStart, optionsEnd, "__cedar_graphqlOptions");
|
|
85
|
+
return {
|
|
86
|
+
code: s.toString(),
|
|
87
|
+
map: s.generateMap({ hires: true })
|
|
88
|
+
};
|
|
84
89
|
}
|
|
85
90
|
export {
|
|
86
91
|
applyGraphqlOptionsExtract,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2636",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
"@babel/parser": "7.29.7",
|
|
64
64
|
"@babel/traverse": "7.29.7",
|
|
65
65
|
"@babel/types": "7.29.7",
|
|
66
|
-
"@cedarjs/api": "6.0.0-canary.
|
|
67
|
-
"@cedarjs/babel-config": "6.0.0-canary.
|
|
68
|
-
"@cedarjs/context": "6.0.0-canary.
|
|
69
|
-
"@cedarjs/cookie-jar": "6.0.0-canary.
|
|
70
|
-
"@cedarjs/graphql-server": "6.0.0-canary.
|
|
71
|
-
"@cedarjs/internal": "6.0.0-canary.
|
|
72
|
-
"@cedarjs/project-config": "6.0.0-canary.
|
|
73
|
-
"@cedarjs/server-store": "6.0.0-canary.
|
|
74
|
-
"@cedarjs/testing": "6.0.0-canary.
|
|
66
|
+
"@cedarjs/api": "6.0.0-canary.2636",
|
|
67
|
+
"@cedarjs/babel-config": "6.0.0-canary.2636",
|
|
68
|
+
"@cedarjs/context": "6.0.0-canary.2636",
|
|
69
|
+
"@cedarjs/cookie-jar": "6.0.0-canary.2636",
|
|
70
|
+
"@cedarjs/graphql-server": "6.0.0-canary.2636",
|
|
71
|
+
"@cedarjs/internal": "6.0.0-canary.2636",
|
|
72
|
+
"@cedarjs/project-config": "6.0.0-canary.2636",
|
|
73
|
+
"@cedarjs/server-store": "6.0.0-canary.2636",
|
|
74
|
+
"@cedarjs/testing": "6.0.0-canary.2636",
|
|
75
75
|
"@fastify/url-data": "6.0.3",
|
|
76
76
|
"@swc/core": "1.15.41",
|
|
77
77
|
"@universal-deploy/store": "^0.2.1",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"find-my-way": "8.2.2",
|
|
93
93
|
"http-proxy-middleware": "3.0.7",
|
|
94
94
|
"isbot": "5.1.43",
|
|
95
|
+
"magic-string": "0.30.21",
|
|
95
96
|
"oxc-parser": "0.137.0",
|
|
96
97
|
"react": "19.2.3",
|
|
97
98
|
"react-server-dom-webpack": "19.2.4",
|
|
@@ -106,9 +107,9 @@
|
|
|
106
107
|
},
|
|
107
108
|
"devDependencies": {
|
|
108
109
|
"@arethetypeswrong/cli": "0.18.5",
|
|
109
|
-
"@cedarjs/auth": "6.0.0-canary.
|
|
110
|
-
"@cedarjs/router": "6.0.0-canary.
|
|
111
|
-
"@cedarjs/web": "6.0.0-canary.
|
|
110
|
+
"@cedarjs/auth": "6.0.0-canary.2636",
|
|
111
|
+
"@cedarjs/router": "6.0.0-canary.2636",
|
|
112
|
+
"@cedarjs/web": "6.0.0-canary.2636",
|
|
112
113
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
113
114
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
114
115
|
"@types/aws-lambda": "8.10.162",
|