@cedarjs/vite 1.0.0-canary.12403 → 1.0.0-canary.12408

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cjs/index.js +51 -132
  2. package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +92 -0
  3. package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +67 -0
  4. package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +43 -0
  5. package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +76 -0
  6. package/dist/cjs/plugins/vite-plugin-jsx-loader.js +3 -3
  7. package/dist/cjs/plugins/vite-plugin-merged-config.js +39 -0
  8. package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +8 -3
  9. package/dist/index.d.ts +14 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +40 -135
  12. package/dist/plugins/vite-plugin-cedar-cell.d.ts +1 -1
  13. package/dist/plugins/vite-plugin-cedar-entry-injection.d.ts +3 -0
  14. package/dist/plugins/vite-plugin-cedar-entry-injection.d.ts.map +1 -0
  15. package/dist/plugins/vite-plugin-cedar-entry-injection.js +58 -0
  16. package/dist/plugins/vite-plugin-cedar-html-env.d.ts +8 -0
  17. package/dist/plugins/vite-plugin-cedar-html-env.d.ts.map +1 -0
  18. package/dist/plugins/vite-plugin-cedar-html-env.js +43 -0
  19. package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +3 -0
  20. package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +1 -0
  21. package/dist/plugins/vite-plugin-cedar-node-polyfills.js +19 -0
  22. package/dist/plugins/vite-plugin-cedar-remove-from-bundle.d.ts +16 -0
  23. package/dist/plugins/vite-plugin-cedar-remove-from-bundle.d.ts.map +1 -0
  24. package/dist/plugins/vite-plugin-cedar-remove-from-bundle.js +41 -0
  25. package/dist/plugins/vite-plugin-jsx-loader.d.ts +1 -3
  26. package/dist/plugins/vite-plugin-jsx-loader.d.ts.map +1 -1
  27. package/dist/plugins/vite-plugin-jsx-loader.js +2 -2
  28. package/dist/plugins/vite-plugin-merged-config.d.ts +3 -0
  29. package/dist/plugins/vite-plugin-merged-config.d.ts.map +1 -0
  30. package/dist/plugins/vite-plugin-merged-config.js +15 -0
  31. package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +4 -6
  32. package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
  33. package/dist/plugins/vite-plugin-swap-apollo-provider.js +7 -2
  34. package/package.json +9 -13
  35. package/dist/cjs/plugins/index.js +0 -43
  36. package/dist/cjs/plugins/vite-plugin-remove-from-bundle.js +0 -56
  37. package/dist/plugins/index.d.ts +0 -7
  38. package/dist/plugins/index.d.ts.map +0 -1
  39. package/dist/plugins/index.js +0 -14
  40. package/dist/plugins/vite-plugin-remove-from-bundle.d.ts +0 -17
  41. package/dist/plugins/vite-plugin-remove-from-bundle.d.ts.map +0 -1
  42. package/dist/plugins/vite-plugin-remove-from-bundle.js +0 -31
package/dist/cjs/index.js CHANGED
@@ -28,34 +28,43 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var index_exports = {};
30
30
  __export(index_exports, {
31
- default: () => redwoodPluginVite
31
+ cedar: () => cedar,
32
+ cedarCellTransform: () => import_vite_plugin_cedar_cell2.cedarCellTransform,
33
+ cedarEntryInjectionPlugin: () => import_vite_plugin_cedar_entry_injection2.cedarEntryInjectionPlugin,
34
+ cedarHtmlEnvPlugin: () => import_vite_plugin_cedar_html_env2.cedarHtmlEnvPlugin,
35
+ cedarMergedConfig: () => import_vite_plugin_merged_config2.cedarMergedConfig,
36
+ cedarNodePolyfills: () => import_vite_plugin_cedar_node_polyfills2.cedarNodePolyfills,
37
+ cedarRemoveFromBundle: () => import_vite_plugin_cedar_remove_from_bundle2.cedarRemoveFromBundle,
38
+ cedarSwapApolloProvider: () => import_vite_plugin_swap_apollo_provider2.cedarSwapApolloProvider,
39
+ cedarTransformJsAsJsx: () => import_vite_plugin_jsx_loader2.cedarTransformJsAsJsx,
40
+ cedarjsDirectoryNamedImportPlugin: () => import_vite_plugin_cedarjs_directory_named_import.cedarjsDirectoryNamedImportPlugin,
41
+ cedarjsJobPathInjectorPlugin: () => import_vite_plugin_cedarjs_job_path_injector.cedarjsJobPathInjectorPlugin,
42
+ default: () => index_default
32
43
  });
33
44
  module.exports = __toCommonJS(index_exports);
34
- var import_fs = __toESM(require("fs"), 1);
35
- var import_path = __toESM(require("path"), 1);
36
45
  var import_plugin_react = __toESM(require("@vitejs/plugin-react"), 1);
37
- var import_vite = require("vite");
38
- var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
39
46
  var import_babel_config = require("@cedarjs/babel-config");
40
47
  var import_project_config = require("@cedarjs/project-config");
41
- var import_getMergedConfig = require("./lib/getMergedConfig.js");
42
48
  var import_vite_plugin_cedar_cell = require("./plugins/vite-plugin-cedar-cell.js");
49
+ var import_vite_plugin_cedar_entry_injection = require("./plugins/vite-plugin-cedar-entry-injection.js");
50
+ var import_vite_plugin_cedar_html_env = require("./plugins/vite-plugin-cedar-html-env.js");
51
+ var import_vite_plugin_cedar_node_polyfills = require("./plugins/vite-plugin-cedar-node-polyfills.js");
52
+ var import_vite_plugin_cedar_remove_from_bundle = require("./plugins/vite-plugin-cedar-remove-from-bundle.js");
43
53
  var import_vite_plugin_jsx_loader = require("./plugins/vite-plugin-jsx-loader.js");
44
- var import_vite_plugin_remove_from_bundle = require("./plugins/vite-plugin-remove-from-bundle.js");
54
+ var import_vite_plugin_merged_config = require("./plugins/vite-plugin-merged-config.js");
45
55
  var import_vite_plugin_swap_apollo_provider = require("./plugins/vite-plugin-swap-apollo-provider.js");
46
- function redwoodPluginVite() {
47
- const rwPaths = (0, import_project_config.getPaths)();
56
+ var import_vite_plugin_cedar_cell2 = require("./plugins/vite-plugin-cedar-cell.js");
57
+ var import_vite_plugin_cedar_entry_injection2 = require("./plugins/vite-plugin-cedar-entry-injection.js");
58
+ var import_vite_plugin_cedar_html_env2 = require("./plugins/vite-plugin-cedar-html-env.js");
59
+ var import_vite_plugin_cedar_node_polyfills2 = require("./plugins/vite-plugin-cedar-node-polyfills.js");
60
+ var import_vite_plugin_cedar_remove_from_bundle2 = require("./plugins/vite-plugin-cedar-remove-from-bundle.js");
61
+ var import_vite_plugin_cedarjs_directory_named_import = require("./plugins/vite-plugin-cedarjs-directory-named-import.js");
62
+ var import_vite_plugin_cedarjs_job_path_injector = require("./plugins/vite-plugin-cedarjs-job-path-injector.js");
63
+ var import_vite_plugin_jsx_loader2 = require("./plugins/vite-plugin-jsx-loader.js");
64
+ var import_vite_plugin_merged_config2 = require("./plugins/vite-plugin-merged-config.js");
65
+ var import_vite_plugin_swap_apollo_provider2 = require("./plugins/vite-plugin-swap-apollo-provider.js");
66
+ function cedar() {
48
67
  const rwConfig = (0, import_project_config.getConfig)();
49
- const clientEntryPath = rwPaths.web.entryClient;
50
- if (!clientEntryPath) {
51
- throw new Error(
52
- "Vite client entry point not found. Please check that your project has an entry.client.{jsx,tsx} file in the web/src directory."
53
- );
54
- }
55
- const relativeEntryPath = import_path.default.relative(rwPaths.web.src, clientEntryPath);
56
- const apiPackageJsonPath = import_path.default.join(rwPaths.api.base, "package.json");
57
- const realtimeEnabled = import_fs.default.existsSync(apiPackageJsonPath) && import_fs.default.readFileSync(apiPackageJsonPath, "utf-8").includes("@cedarjs/realtime");
58
- const streamingEnabled = rwConfig.experimental.streamingSsr.enabled;
59
68
  const rscEnabled = rwConfig.experimental?.rsc?.enabled;
60
69
  const webSideDefaultBabelConfig = (0, import_babel_config.getWebSideDefaultBabelConfig)();
61
70
  const babelConfig = {
@@ -69,119 +78,29 @@ function redwoodPluginVite() {
69
78
  }) : webSideDefaultBabelConfig.overrides
70
79
  };
71
80
  return [
72
- // Only include the Buffer polyfill for non-rsc dev, for DevFatalErrorPage
73
- // Including the polyfill plugin in any form in RSC breaks
74
- !rscEnabled && {
75
- ...(0, import_vite_plugin_node_polyfills.nodePolyfills)({
76
- include: ["buffer"],
77
- globals: {
78
- Buffer: true
79
- }
80
- }),
81
- apply: "serve"
82
- },
83
- {
84
- name: "redwood-plugin-vite-html-env",
85
- // Vite can support replacing environment variables in index.html but
86
- // there are currently two issues with that:
87
- // 1. It requires the environment variables to be exposed on
88
- // `import.meta.env`, but we expose them on `process.env` in Redwood.
89
- // 2. There's an open issue on Vite where it adds extra quotes around
90
- // the replaced values, which breaks trying to use environment
91
- // variables in src attributes for example.
92
- // Until those issues are resolved, we'll do the replacement ourselves
93
- // instead using transformIndexHtml. Doing it this was was also the
94
- // recommended way until Vite added built-in support for it.
95
- //
96
- // Extra quotes issue: https://github.com/vitejs/vite/issues/13424
97
- // transformIndexHtml being the recommended way:
98
- // https://github.com/vitejs/vite/issues/3105#issuecomment-1059975023
99
- transformIndexHtml: {
100
- // Setting order: 'pre' so that it runs before the built-in
101
- // html env replacement.
102
- order: "pre",
103
- handler: (html) => {
104
- let newHtml = html;
105
- rwConfig.web.includeEnvironmentVariables.map((envName) => {
106
- newHtml = newHtml.replaceAll(
107
- `%${envName}%`,
108
- process.env[envName] || ""
109
- );
110
- });
111
- Object.entries(process.env).forEach(([envName, value]) => {
112
- if (envName.startsWith("REDWOOD_ENV_")) {
113
- newHtml = newHtml.replaceAll(`%${envName}%`, value || "");
114
- }
115
- });
116
- return newHtml;
117
- }
118
- }
119
- },
120
- {
121
- name: "redwood-plugin-vite",
122
- // ---------- Bundle injection ----------
123
- // Used by Vite during dev, to inject the entrypoint.
124
- transformIndexHtml: {
125
- order: "pre",
126
- handler: (html) => {
127
- if (import_fs.default.existsSync(clientEntryPath)) {
128
- return html.replace(
129
- "</head>",
130
- // @NOTE the slash in front, for windows compatibility and for pages in subdirectories
131
- `<script type="module" src="/${relativeEntryPath}"></script>
132
- </head>`
133
- );
134
- } else {
135
- return html;
136
- }
137
- }
138
- },
139
- // Used by rollup during build to inject the entrypoint
140
- // but note index.html does not come through as an id during dev
141
- transform: (code, id) => {
142
- if (import_fs.default.existsSync(clientEntryPath) && (0, import_vite.normalizePath)(id) === (0, import_vite.normalizePath)(rwPaths.web.html)) {
143
- return {
144
- code: code.replace(
145
- "</head>",
146
- `<script type="module" src="/${relativeEntryPath}"></script>
147
- </head>`
148
- ),
149
- map: null
150
- };
151
- } else {
152
- return {
153
- code,
154
- map: null
155
- // Returning null here preserves the original sourcemap
156
- };
157
- }
158
- },
159
- // ---------- End Bundle injection ----------
160
- // @MARK: Using the config hook here let's us modify the config
161
- // but returning plugins will **not** work
162
- config: (0, import_getMergedConfig.getMergedConfig)(rwConfig, rwPaths)
163
- },
164
- // We can remove when streaming is stable
165
- streamingEnabled && (0, import_vite_plugin_swap_apollo_provider.swapApolloProvider)(),
166
- // Transform files ending with 'Cell' to wrap them in createCell HOC
81
+ (0, import_vite_plugin_cedar_node_polyfills.cedarNodePolyfills)(),
82
+ (0, import_vite_plugin_cedar_html_env.cedarHtmlEnvPlugin)(),
83
+ (0, import_vite_plugin_cedar_entry_injection.cedarEntryInjectionPlugin)(),
84
+ (0, import_vite_plugin_merged_config.cedarMergedConfig)(),
85
+ (0, import_vite_plugin_swap_apollo_provider.cedarSwapApolloProvider)(),
167
86
  (0, import_vite_plugin_cedar_cell.cedarCellTransform)(),
168
- (0, import_vite_plugin_jsx_loader.handleJsAsJsx)(),
169
- // Remove the splash-page from the bundle.
170
- (0, import_vite_plugin_remove_from_bundle.removeFromBundle)(
171
- [
172
- {
173
- id: /@cedarjs\/router\/dist\/splash-page/
174
- }
175
- ],
176
- ["SplashPage"]
177
- ),
178
- !realtimeEnabled && (0, import_vite_plugin_remove_from_bundle.removeFromBundle)([
179
- {
180
- id: /@cedarjs\/web\/dist\/apollo\/sseLink/
181
- }
182
- ]),
183
- (0, import_plugin_react.default)({
184
- babel: babelConfig
185
- })
87
+ (0, import_vite_plugin_jsx_loader.cedarTransformJsAsJsx)(),
88
+ (0, import_vite_plugin_cedar_remove_from_bundle.cedarRemoveFromBundle)(),
89
+ (0, import_plugin_react.default)({ babel: babelConfig })
186
90
  ];
187
91
  }
92
+ var index_default = cedar;
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ cedar,
96
+ cedarCellTransform,
97
+ cedarEntryInjectionPlugin,
98
+ cedarHtmlEnvPlugin,
99
+ cedarMergedConfig,
100
+ cedarNodePolyfills,
101
+ cedarRemoveFromBundle,
102
+ cedarSwapApolloProvider,
103
+ cedarTransformJsAsJsx,
104
+ cedarjsDirectoryNamedImportPlugin,
105
+ cedarjsJobPathInjectorPlugin
106
+ });
@@ -0,0 +1,92 @@
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_entry_injection_exports = {};
30
+ __export(vite_plugin_cedar_entry_injection_exports, {
31
+ cedarEntryInjectionPlugin: () => cedarEntryInjectionPlugin
32
+ });
33
+ module.exports = __toCommonJS(vite_plugin_cedar_entry_injection_exports);
34
+ var import_node_fs = __toESM(require("node:fs"), 1);
35
+ var import_node_path = __toESM(require("node:path"), 1);
36
+ var import_vite = require("vite");
37
+ var import_project_config = require("@cedarjs/project-config");
38
+ function cedarEntryInjectionPlugin() {
39
+ const rwPaths = (0, import_project_config.getPaths)();
40
+ const clientEntryPath = rwPaths.web.entryClient;
41
+ if (!clientEntryPath) {
42
+ throw new Error(
43
+ "Vite client entry point not found. Please check that your project has an entry.client.{jsx,tsx} file in the web/src directory."
44
+ );
45
+ }
46
+ const relativeEntryPath = import_node_path.default.relative(rwPaths.web.src, clientEntryPath);
47
+ return {
48
+ name: "cedar-entry-injection",
49
+ // ---------- Bundle injection ----------
50
+ // Used by Vite during dev, to inject the entrypoint.
51
+ transformIndexHtml: {
52
+ order: "pre",
53
+ handler: (html) => {
54
+ if (import_node_fs.default.existsSync(clientEntryPath)) {
55
+ return html.replace(
56
+ "</head>",
57
+ // @NOTE the slash in front, for windows compatibility and for
58
+ // pages in subdirectories
59
+ `<script type="module" src="/${relativeEntryPath}"></script>
60
+ </head>`
61
+ );
62
+ } else {
63
+ return html;
64
+ }
65
+ }
66
+ },
67
+ // Used by rollup during build to inject the entrypoint
68
+ // but note index.html does not come through as an id during dev
69
+ transform: (code, id) => {
70
+ if (import_node_fs.default.existsSync(clientEntryPath) && (0, import_vite.normalizePath)(id) === (0, import_vite.normalizePath)(rwPaths.web.html)) {
71
+ return {
72
+ code: code.replace(
73
+ "</head>",
74
+ `<script type="module" src="/${relativeEntryPath}"></script>
75
+ </head>`
76
+ ),
77
+ map: null
78
+ };
79
+ } else {
80
+ return {
81
+ code,
82
+ map: null
83
+ // Returning null here preserves the original sourcemap
84
+ };
85
+ }
86
+ }
87
+ };
88
+ }
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {
91
+ cedarEntryInjectionPlugin
92
+ });
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var vite_plugin_cedar_html_env_exports = {};
20
+ __export(vite_plugin_cedar_html_env_exports, {
21
+ cedarHtmlEnvPlugin: () => cedarHtmlEnvPlugin
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_cedar_html_env_exports);
24
+ var import_project_config = require("@cedarjs/project-config");
25
+ function cedarHtmlEnvPlugin() {
26
+ return {
27
+ name: "cedar-html-env",
28
+ // Vite can support replacing environment variables in index.html but
29
+ // there are currently two issues with that:
30
+ // 1. It requires the environment variables to be exposed on
31
+ // `import.meta.env`, but we expose them on `process.env` in Redwood.
32
+ // 2. There's an open issue on Vite where it adds extra quotes around
33
+ // the replaced values, which breaks trying to use environment
34
+ // variables in src attributes for example.
35
+ // Until those issues are resolved, we'll do the replacement ourselves
36
+ // instead using transformIndexHtml. Doing it this was was also the
37
+ // recommended way until Vite added built-in support for it.
38
+ //
39
+ // Extra quotes issue: https://github.com/vitejs/vite/issues/13424
40
+ // transformIndexHtml being the recommended way:
41
+ // https://github.com/vitejs/vite/issues/3105#issuecomment-1059975023
42
+ transformIndexHtml: {
43
+ // Setting order: 'pre' so that it runs before the built-in
44
+ // html env replacement.
45
+ order: "pre",
46
+ handler: (html) => {
47
+ let newHtml = html;
48
+ (0, import_project_config.getConfig)().web.includeEnvironmentVariables.map((envName) => {
49
+ newHtml = newHtml.replaceAll(
50
+ `%${envName}%`,
51
+ process.env[envName] || ""
52
+ );
53
+ });
54
+ Object.entries(process.env).forEach(([envName, value]) => {
55
+ if (envName.startsWith("REDWOOD_ENV_")) {
56
+ newHtml = newHtml.replaceAll(`%${envName}%`, value || "");
57
+ }
58
+ });
59
+ return newHtml;
60
+ }
61
+ }
62
+ };
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ cedarHtmlEnvPlugin
67
+ });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var vite_plugin_cedar_node_polyfills_exports = {};
20
+ __export(vite_plugin_cedar_node_polyfills_exports, {
21
+ cedarNodePolyfills: () => cedarNodePolyfills
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_cedar_node_polyfills_exports);
24
+ var import_vite_plugin_node_polyfills = require("vite-plugin-node-polyfills");
25
+ var import_project_config = require("@cedarjs/project-config");
26
+ function cedarNodePolyfills() {
27
+ if ((0, import_project_config.getConfig)().experimental?.rsc?.enabled) {
28
+ return void 0;
29
+ }
30
+ return {
31
+ ...(0, import_vite_plugin_node_polyfills.nodePolyfills)({
32
+ include: ["buffer"],
33
+ globals: {
34
+ Buffer: true
35
+ }
36
+ }),
37
+ apply: "serve"
38
+ };
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ cedarNodePolyfills
43
+ });
@@ -0,0 +1,76 @@
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_remove_from_bundle_exports = {};
30
+ __export(vite_plugin_cedar_remove_from_bundle_exports, {
31
+ cedarRemoveFromBundle: () => cedarRemoveFromBundle,
32
+ excludeOnMatch: () => excludeOnMatch
33
+ });
34
+ module.exports = __toCommonJS(vite_plugin_cedar_remove_from_bundle_exports);
35
+ var import_node_fs = __toESM(require("node:fs"), 1);
36
+ var import_node_path = __toESM(require("node:path"), 1);
37
+ var import_project_config = require("@cedarjs/project-config");
38
+ function cedarRemoveFromBundle() {
39
+ const apiPackageJsonPath = import_node_path.default.join((0, import_project_config.getPaths)().api.base, "package.json");
40
+ const realtimeEnabled = import_node_fs.default.existsSync(apiPackageJsonPath) && import_node_fs.default.readFileSync(apiPackageJsonPath, "utf-8").includes("@cedarjs/realtime");
41
+ const modulesToExclude = [
42
+ {
43
+ id: /@cedarjs\/router\/dist\/splash-page/,
44
+ exportNames: ["SplashPage"]
45
+ }
46
+ ];
47
+ if (!realtimeEnabled) {
48
+ modulesToExclude.push({
49
+ id: /@cedarjs\/web\/dist\/apollo\/sseLink/
50
+ });
51
+ }
52
+ return {
53
+ name: "remove-from-bundle",
54
+ apply: "build",
55
+ load: (id) => {
56
+ return excludeOnMatch(modulesToExclude, id);
57
+ }
58
+ };
59
+ }
60
+ function generateModuleWithExports(exportNames) {
61
+ return {
62
+ code: `export default {}; ${exportNames.map((name) => `export const ${name} = undefined;`).join("\n")}`
63
+ };
64
+ }
65
+ function excludeOnMatch(modulesToExclude, id) {
66
+ const moduleToExclude = modulesToExclude.find((module2) => module2.id.test(id));
67
+ if (moduleToExclude) {
68
+ return generateModuleWithExports(moduleToExclude.exportNames || []);
69
+ }
70
+ return null;
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ cedarRemoveFromBundle,
75
+ excludeOnMatch
76
+ });
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var vite_plugin_jsx_loader_exports = {};
20
20
  __export(vite_plugin_jsx_loader_exports, {
21
- handleJsAsJsx: () => handleJsAsJsx
21
+ cedarTransformJsAsJsx: () => cedarTransformJsAsJsx
22
22
  });
23
23
  module.exports = __toCommonJS(vite_plugin_jsx_loader_exports);
24
24
  var import_vite = require("vite");
25
- function handleJsAsJsx() {
25
+ function cedarTransformJsAsJsx() {
26
26
  return {
27
27
  name: "transform-js-files-as-jsx",
28
28
  async transform(code, id) {
@@ -38,5 +38,5 @@ function handleJsAsJsx() {
38
38
  }
39
39
  // Annotate the CommonJS export names for ESM import in node:
40
40
  0 && (module.exports = {
41
- handleJsAsJsx
41
+ cedarTransformJsAsJsx
42
42
  });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var vite_plugin_merged_config_exports = {};
20
+ __export(vite_plugin_merged_config_exports, {
21
+ cedarMergedConfig: () => cedarMergedConfig
22
+ });
23
+ module.exports = __toCommonJS(vite_plugin_merged_config_exports);
24
+ var import_project_config = require("@cedarjs/project-config");
25
+ var import_getMergedConfig = require("../lib/getMergedConfig.js");
26
+ function cedarMergedConfig() {
27
+ const rwPaths = (0, import_project_config.getPaths)();
28
+ const rwConfig = (0, import_project_config.getConfig)();
29
+ return {
30
+ name: "vite-plugin-cedar",
31
+ // Using the config hook here lets us modify the config but returning
32
+ // plugins will **not** work
33
+ config: (0, import_getMergedConfig.getMergedConfig)(rwConfig, rwPaths)
34
+ };
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ cedarMergedConfig
39
+ });
@@ -18,10 +18,15 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var vite_plugin_swap_apollo_provider_exports = {};
20
20
  __export(vite_plugin_swap_apollo_provider_exports, {
21
- swapApolloProvider: () => swapApolloProvider
21
+ cedarSwapApolloProvider: () => cedarSwapApolloProvider
22
22
  });
23
23
  module.exports = __toCommonJS(vite_plugin_swap_apollo_provider_exports);
24
- function swapApolloProvider() {
24
+ var import_project_config = require("@cedarjs/project-config");
25
+ function cedarSwapApolloProvider() {
26
+ const streamingEnabled = (0, import_project_config.getConfig)().experimental.streamingSsr.enabled;
27
+ if (!streamingEnabled) {
28
+ return void 0;
29
+ }
25
30
  return {
26
31
  name: "redwood-swap-apollo-provider",
27
32
  async transform(code, id) {
@@ -37,5 +42,5 @@ function swapApolloProvider() {
37
42
  }
38
43
  // Annotate the CommonJS export names for ESM import in node:
39
44
  0 && (module.exports = {
40
- swapApolloProvider
45
+ cedarSwapApolloProvider
41
46
  });
package/dist/index.d.ts CHANGED
@@ -1,6 +1,18 @@
1
1
  import type { PluginOption } from 'vite';
2
+ export { cedarCellTransform } from './plugins/vite-plugin-cedar-cell.js';
3
+ export { cedarEntryInjectionPlugin } from './plugins/vite-plugin-cedar-entry-injection.js';
4
+ export { cedarHtmlEnvPlugin } from './plugins/vite-plugin-cedar-html-env.js';
5
+ export { cedarNodePolyfills } from './plugins/vite-plugin-cedar-node-polyfills.js';
6
+ export { cedarRemoveFromBundle } from './plugins/vite-plugin-cedar-remove-from-bundle.js';
7
+ export { cedarjsDirectoryNamedImportPlugin } from './plugins/vite-plugin-cedarjs-directory-named-import.js';
8
+ export { cedarjsJobPathInjectorPlugin } from './plugins/vite-plugin-cedarjs-job-path-injector.js';
9
+ export { cedarTransformJsAsJsx } from './plugins/vite-plugin-jsx-loader.js';
10
+ export { cedarMergedConfig } from './plugins/vite-plugin-merged-config.js';
11
+ export { cedarSwapApolloProvider } from './plugins/vite-plugin-swap-apollo-provider.js';
2
12
  /**
3
- * Pre-configured vite plugin, with required config for Redwood apps.
13
+ * Pre-configured vite plugin, with required config for CedarJS apps.
4
14
  */
5
- export default function redwoodPluginVite(): PluginOption[];
15
+ export declare function cedar(): PluginOption[];
16
+ /** @deprecated - Please use the named `cedar` export instead */
17
+ export default cedar;
6
18
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAaxC;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,IAAI,YAAY,EAAE,CA0K1D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAcxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAA;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAA;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,yDAAyD,CAAA;AAC3G,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAA;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AAEvF;;GAEG;AACH,wBAAgB,KAAK,IAAI,YAAY,EAAE,CAkCtC;AAED,gEAAgE;AAChE,eAAe,KAAK,CAAA"}