@cedarjs/vite 0.4.0 → 0.5.0
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/cjs/index.js +51 -132
- package/dist/cjs/plugins/vite-plugin-cedar-entry-injection.js +92 -0
- package/dist/cjs/plugins/vite-plugin-cedar-html-env.js +67 -0
- package/dist/cjs/plugins/vite-plugin-cedar-node-polyfills.js +43 -0
- package/dist/cjs/plugins/vite-plugin-cedar-remove-from-bundle.js +76 -0
- package/dist/cjs/plugins/vite-plugin-jsx-loader.js +3 -3
- package/dist/cjs/plugins/vite-plugin-merged-config.js +39 -0
- package/dist/cjs/plugins/vite-plugin-swap-apollo-provider.js +8 -3
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -135
- package/dist/plugins/vite-plugin-cedar-cell.d.ts +1 -1
- package/dist/plugins/vite-plugin-cedar-entry-injection.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-entry-injection.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-entry-injection.js +58 -0
- package/dist/plugins/vite-plugin-cedar-html-env.d.ts +8 -0
- package/dist/plugins/vite-plugin-cedar-html-env.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-html-env.js +43 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts +3 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-node-polyfills.js +19 -0
- package/dist/plugins/vite-plugin-cedar-remove-from-bundle.d.ts +16 -0
- package/dist/plugins/vite-plugin-cedar-remove-from-bundle.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-cedar-remove-from-bundle.js +41 -0
- package/dist/plugins/vite-plugin-jsx-loader.d.ts +1 -3
- package/dist/plugins/vite-plugin-jsx-loader.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-jsx-loader.js +2 -2
- package/dist/plugins/vite-plugin-merged-config.d.ts +3 -0
- package/dist/plugins/vite-plugin-merged-config.d.ts.map +1 -0
- package/dist/plugins/vite-plugin-merged-config.js +15 -0
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts +4 -6
- package/dist/plugins/vite-plugin-swap-apollo-provider.d.ts.map +1 -1
- package/dist/plugins/vite-plugin-swap-apollo-provider.js +7 -2
- package/package.json +12 -16
- package/dist/cjs/plugins/index.js +0 -43
- package/dist/cjs/plugins/vite-plugin-remove-from-bundle.js +0 -56
- package/dist/plugins/index.d.ts +0 -7
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -14
- package/dist/plugins/vite-plugin-remove-from-bundle.d.ts +0 -17
- package/dist/plugins/vite-plugin-remove-from-bundle.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-remove-from-bundle.js +0 -31
package/dist/index.js
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
1
|
import react from "@vitejs/plugin-react";
|
|
4
|
-
import { normalizePath } from "vite";
|
|
5
|
-
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
6
2
|
import { getWebSideDefaultBabelConfig } from "@cedarjs/babel-config";
|
|
7
|
-
import { getConfig
|
|
8
|
-
import { getMergedConfig } from "./lib/getMergedConfig.js";
|
|
3
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
9
4
|
import { cedarCellTransform } from "./plugins/vite-plugin-cedar-cell.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
import { cedarEntryInjectionPlugin } from "./plugins/vite-plugin-cedar-entry-injection.js";
|
|
6
|
+
import { cedarHtmlEnvPlugin } from "./plugins/vite-plugin-cedar-html-env.js";
|
|
7
|
+
import { cedarNodePolyfills } from "./plugins/vite-plugin-cedar-node-polyfills.js";
|
|
8
|
+
import { cedarRemoveFromBundle } from "./plugins/vite-plugin-cedar-remove-from-bundle.js";
|
|
9
|
+
import { cedarTransformJsAsJsx } from "./plugins/vite-plugin-jsx-loader.js";
|
|
10
|
+
import { cedarMergedConfig } from "./plugins/vite-plugin-merged-config.js";
|
|
11
|
+
import { cedarSwapApolloProvider } from "./plugins/vite-plugin-swap-apollo-provider.js";
|
|
12
|
+
import { cedarCellTransform as cedarCellTransform2 } from "./plugins/vite-plugin-cedar-cell.js";
|
|
13
|
+
import { cedarEntryInjectionPlugin as cedarEntryInjectionPlugin2 } from "./plugins/vite-plugin-cedar-entry-injection.js";
|
|
14
|
+
import { cedarHtmlEnvPlugin as cedarHtmlEnvPlugin2 } from "./plugins/vite-plugin-cedar-html-env.js";
|
|
15
|
+
import { cedarNodePolyfills as cedarNodePolyfills2 } from "./plugins/vite-plugin-cedar-node-polyfills.js";
|
|
16
|
+
import { cedarRemoveFromBundle as cedarRemoveFromBundle2 } from "./plugins/vite-plugin-cedar-remove-from-bundle.js";
|
|
17
|
+
import { cedarjsDirectoryNamedImportPlugin } from "./plugins/vite-plugin-cedarjs-directory-named-import.js";
|
|
18
|
+
import { cedarjsJobPathInjectorPlugin } from "./plugins/vite-plugin-cedarjs-job-path-injector.js";
|
|
19
|
+
import { cedarTransformJsAsJsx as cedarTransformJsAsJsx2 } from "./plugins/vite-plugin-jsx-loader.js";
|
|
20
|
+
import { cedarMergedConfig as cedarMergedConfig2 } from "./plugins/vite-plugin-merged-config.js";
|
|
21
|
+
import { cedarSwapApolloProvider as cedarSwapApolloProvider2 } from "./plugins/vite-plugin-swap-apollo-provider.js";
|
|
22
|
+
function cedar() {
|
|
15
23
|
const rwConfig = getConfig();
|
|
16
|
-
const clientEntryPath = rwPaths.web.entryClient;
|
|
17
|
-
if (!clientEntryPath) {
|
|
18
|
-
throw new Error(
|
|
19
|
-
"Vite client entry point not found. Please check that your project has an entry.client.{jsx,tsx} file in the web/src directory."
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
const relativeEntryPath = path.relative(rwPaths.web.src, clientEntryPath);
|
|
23
|
-
const apiPackageJsonPath = path.join(rwPaths.api.base, "package.json");
|
|
24
|
-
const realtimeEnabled = fs.existsSync(apiPackageJsonPath) && fs.readFileSync(apiPackageJsonPath, "utf-8").includes("@cedarjs/realtime");
|
|
25
|
-
const streamingEnabled = rwConfig.experimental.streamingSsr.enabled;
|
|
26
24
|
const rscEnabled = rwConfig.experimental?.rsc?.enabled;
|
|
27
25
|
const webSideDefaultBabelConfig = getWebSideDefaultBabelConfig();
|
|
28
26
|
const babelConfig = {
|
|
@@ -36,122 +34,29 @@ function redwoodPluginVite() {
|
|
|
36
34
|
}) : webSideDefaultBabelConfig.overrides
|
|
37
35
|
};
|
|
38
36
|
return [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
globals: {
|
|
45
|
-
Buffer: true
|
|
46
|
-
}
|
|
47
|
-
}),
|
|
48
|
-
apply: "serve"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "redwood-plugin-vite-html-env",
|
|
52
|
-
// Vite can support replacing environment variables in index.html but
|
|
53
|
-
// there are currently two issues with that:
|
|
54
|
-
// 1. It requires the environment variables to be exposed on
|
|
55
|
-
// `import.meta.env`, but we expose them on `process.env` in Redwood.
|
|
56
|
-
// 2. There's an open issue on Vite where it adds extra quotes around
|
|
57
|
-
// the replaced values, which breaks trying to use environment
|
|
58
|
-
// variables in src attributes for example.
|
|
59
|
-
// Until those issues are resolved, we'll do the replacement ourselves
|
|
60
|
-
// instead using transformIndexHtml. Doing it this was was also the
|
|
61
|
-
// recommended way until Vite added built-in support for it.
|
|
62
|
-
//
|
|
63
|
-
// Extra quotes issue: https://github.com/vitejs/vite/issues/13424
|
|
64
|
-
// transformIndexHtml being the recommended way:
|
|
65
|
-
// https://github.com/vitejs/vite/issues/3105#issuecomment-1059975023
|
|
66
|
-
transformIndexHtml: {
|
|
67
|
-
// Setting order: 'pre' so that it runs before the built-in
|
|
68
|
-
// html env replacement.
|
|
69
|
-
order: "pre",
|
|
70
|
-
handler: (html) => {
|
|
71
|
-
let newHtml = html;
|
|
72
|
-
rwConfig.web.includeEnvironmentVariables.map((envName) => {
|
|
73
|
-
newHtml = newHtml.replaceAll(
|
|
74
|
-
`%${envName}%`,
|
|
75
|
-
process.env[envName] || ""
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
Object.entries(process.env).forEach(([envName, value]) => {
|
|
79
|
-
if (envName.startsWith("REDWOOD_ENV_")) {
|
|
80
|
-
newHtml = newHtml.replaceAll(`%${envName}%`, value || "");
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
return newHtml;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
name: "redwood-plugin-vite",
|
|
89
|
-
// ---------- Bundle injection ----------
|
|
90
|
-
// Used by Vite during dev, to inject the entrypoint.
|
|
91
|
-
transformIndexHtml: {
|
|
92
|
-
order: "pre",
|
|
93
|
-
handler: (html) => {
|
|
94
|
-
if (fs.existsSync(clientEntryPath)) {
|
|
95
|
-
return html.replace(
|
|
96
|
-
"</head>",
|
|
97
|
-
// @NOTE the slash in front, for windows compatibility and for pages in subdirectories
|
|
98
|
-
`<script type="module" src="/${relativeEntryPath}"></script>
|
|
99
|
-
</head>`
|
|
100
|
-
);
|
|
101
|
-
} else {
|
|
102
|
-
return html;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
// Used by rollup during build to inject the entrypoint
|
|
107
|
-
// but note index.html does not come through as an id during dev
|
|
108
|
-
transform: (code, id) => {
|
|
109
|
-
if (fs.existsSync(clientEntryPath) && normalizePath(id) === normalizePath(rwPaths.web.html)) {
|
|
110
|
-
return {
|
|
111
|
-
code: code.replace(
|
|
112
|
-
"</head>",
|
|
113
|
-
`<script type="module" src="/${relativeEntryPath}"></script>
|
|
114
|
-
</head>`
|
|
115
|
-
),
|
|
116
|
-
map: null
|
|
117
|
-
};
|
|
118
|
-
} else {
|
|
119
|
-
return {
|
|
120
|
-
code,
|
|
121
|
-
map: null
|
|
122
|
-
// Returning null here preserves the original sourcemap
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
// ---------- End Bundle injection ----------
|
|
127
|
-
// @MARK: Using the config hook here let's us modify the config
|
|
128
|
-
// but returning plugins will **not** work
|
|
129
|
-
config: getMergedConfig(rwConfig, rwPaths)
|
|
130
|
-
},
|
|
131
|
-
// We can remove when streaming is stable
|
|
132
|
-
streamingEnabled && swapApolloProvider(),
|
|
133
|
-
// Transform files ending with 'Cell' to wrap them in createCell HOC
|
|
37
|
+
cedarNodePolyfills(),
|
|
38
|
+
cedarHtmlEnvPlugin(),
|
|
39
|
+
cedarEntryInjectionPlugin(),
|
|
40
|
+
cedarMergedConfig(),
|
|
41
|
+
cedarSwapApolloProvider(),
|
|
134
42
|
cedarCellTransform(),
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
[
|
|
139
|
-
{
|
|
140
|
-
id: /@cedarjs\/router\/dist\/splash-page/
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
["SplashPage"]
|
|
144
|
-
),
|
|
145
|
-
!realtimeEnabled && removeFromBundle([
|
|
146
|
-
{
|
|
147
|
-
id: /@cedarjs\/web\/dist\/apollo\/sseLink/
|
|
148
|
-
}
|
|
149
|
-
]),
|
|
150
|
-
react({
|
|
151
|
-
babel: babelConfig
|
|
152
|
-
})
|
|
43
|
+
cedarTransformJsAsJsx(),
|
|
44
|
+
cedarRemoveFromBundle(),
|
|
45
|
+
react({ babel: babelConfig })
|
|
153
46
|
];
|
|
154
47
|
}
|
|
48
|
+
var index_default = cedar;
|
|
155
49
|
export {
|
|
156
|
-
|
|
50
|
+
cedar,
|
|
51
|
+
cedarCellTransform2 as cedarCellTransform,
|
|
52
|
+
cedarEntryInjectionPlugin2 as cedarEntryInjectionPlugin,
|
|
53
|
+
cedarHtmlEnvPlugin2 as cedarHtmlEnvPlugin,
|
|
54
|
+
cedarMergedConfig2 as cedarMergedConfig,
|
|
55
|
+
cedarNodePolyfills2 as cedarNodePolyfills,
|
|
56
|
+
cedarRemoveFromBundle2 as cedarRemoveFromBundle,
|
|
57
|
+
cedarSwapApolloProvider2 as cedarSwapApolloProvider,
|
|
58
|
+
cedarTransformJsAsJsx2 as cedarTransformJsAsJsx,
|
|
59
|
+
cedarjsDirectoryNamedImportPlugin,
|
|
60
|
+
cedarjsJobPathInjectorPlugin,
|
|
61
|
+
index_default as default
|
|
157
62
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
/**
|
|
3
|
-
* Vite plugin that wraps files with a suffix of `Cell` in
|
|
3
|
+
* Vite plugin that wraps files with a suffix of `Cell` in CedarJS's `createCell`
|
|
4
4
|
* higher order component. The HOC deals with the lifecycle methods during a GraphQL query.
|
|
5
5
|
*
|
|
6
6
|
* This transforms:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-entry-injection.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-entry-injection.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC,wBAAgB,yBAAyB,IAAI,MAAM,CA6DlD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { normalizePath } from "vite";
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
function cedarEntryInjectionPlugin() {
|
|
6
|
+
const rwPaths = getPaths();
|
|
7
|
+
const clientEntryPath = rwPaths.web.entryClient;
|
|
8
|
+
if (!clientEntryPath) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"Vite client entry point not found. Please check that your project has an entry.client.{jsx,tsx} file in the web/src directory."
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
const relativeEntryPath = path.relative(rwPaths.web.src, clientEntryPath);
|
|
14
|
+
return {
|
|
15
|
+
name: "cedar-entry-injection",
|
|
16
|
+
// ---------- Bundle injection ----------
|
|
17
|
+
// Used by Vite during dev, to inject the entrypoint.
|
|
18
|
+
transformIndexHtml: {
|
|
19
|
+
order: "pre",
|
|
20
|
+
handler: (html) => {
|
|
21
|
+
if (fs.existsSync(clientEntryPath)) {
|
|
22
|
+
return html.replace(
|
|
23
|
+
"</head>",
|
|
24
|
+
// @NOTE the slash in front, for windows compatibility and for
|
|
25
|
+
// pages in subdirectories
|
|
26
|
+
`<script type="module" src="/${relativeEntryPath}"></script>
|
|
27
|
+
</head>`
|
|
28
|
+
);
|
|
29
|
+
} else {
|
|
30
|
+
return html;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
// Used by rollup during build to inject the entrypoint
|
|
35
|
+
// but note index.html does not come through as an id during dev
|
|
36
|
+
transform: (code, id) => {
|
|
37
|
+
if (fs.existsSync(clientEntryPath) && normalizePath(id) === normalizePath(rwPaths.web.html)) {
|
|
38
|
+
return {
|
|
39
|
+
code: code.replace(
|
|
40
|
+
"</head>",
|
|
41
|
+
`<script type="module" src="/${relativeEntryPath}"></script>
|
|
42
|
+
</head>`
|
|
43
|
+
),
|
|
44
|
+
map: null
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
return {
|
|
48
|
+
code,
|
|
49
|
+
map: null
|
|
50
|
+
// Returning null here preserves the original sourcemap
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
cedarEntryInjectionPlugin
|
|
58
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-html-env.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-html-env.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB;;;;wBAsBZ,MAAM;;EAoB3B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
2
|
+
function cedarHtmlEnvPlugin() {
|
|
3
|
+
return {
|
|
4
|
+
name: "cedar-html-env",
|
|
5
|
+
// Vite can support replacing environment variables in index.html but
|
|
6
|
+
// there are currently two issues with that:
|
|
7
|
+
// 1. It requires the environment variables to be exposed on
|
|
8
|
+
// `import.meta.env`, but we expose them on `process.env` in Redwood.
|
|
9
|
+
// 2. There's an open issue on Vite where it adds extra quotes around
|
|
10
|
+
// the replaced values, which breaks trying to use environment
|
|
11
|
+
// variables in src attributes for example.
|
|
12
|
+
// Until those issues are resolved, we'll do the replacement ourselves
|
|
13
|
+
// instead using transformIndexHtml. Doing it this was was also the
|
|
14
|
+
// recommended way until Vite added built-in support for it.
|
|
15
|
+
//
|
|
16
|
+
// Extra quotes issue: https://github.com/vitejs/vite/issues/13424
|
|
17
|
+
// transformIndexHtml being the recommended way:
|
|
18
|
+
// https://github.com/vitejs/vite/issues/3105#issuecomment-1059975023
|
|
19
|
+
transformIndexHtml: {
|
|
20
|
+
// Setting order: 'pre' so that it runs before the built-in
|
|
21
|
+
// html env replacement.
|
|
22
|
+
order: "pre",
|
|
23
|
+
handler: (html) => {
|
|
24
|
+
let newHtml = html;
|
|
25
|
+
getConfig().web.includeEnvironmentVariables.map((envName) => {
|
|
26
|
+
newHtml = newHtml.replaceAll(
|
|
27
|
+
`%${envName}%`,
|
|
28
|
+
process.env[envName] || ""
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
Object.entries(process.env).forEach(([envName, value]) => {
|
|
32
|
+
if (envName.startsWith("REDWOOD_ENV_")) {
|
|
33
|
+
newHtml = newHtml.replaceAll(`%${envName}%`, value || "");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return newHtml;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
cedarHtmlEnvPlugin
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-node-polyfills.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-node-polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAiBvD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
2
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
3
|
+
function cedarNodePolyfills() {
|
|
4
|
+
if (getConfig().experimental?.rsc?.enabled) {
|
|
5
|
+
return void 0;
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
...nodePolyfills({
|
|
9
|
+
include: ["buffer"],
|
|
10
|
+
globals: {
|
|
11
|
+
Buffer: true
|
|
12
|
+
}
|
|
13
|
+
}),
|
|
14
|
+
apply: "serve"
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
cedarNodePolyfills
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
type ModulesToExclude = {
|
|
3
|
+
id: RegExp;
|
|
4
|
+
exportNames?: string[];
|
|
5
|
+
}[];
|
|
6
|
+
/**
|
|
7
|
+
* This is a vite plugin to remove modules from the bundle.
|
|
8
|
+
*
|
|
9
|
+
* Only applies on build, not on dev.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cedarRemoveFromBundle(): Plugin;
|
|
12
|
+
export declare function excludeOnMatch(modulesToExclude: ModulesToExclude, id: string): {
|
|
13
|
+
code: string;
|
|
14
|
+
} | null;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=vite-plugin-cedar-remove-from-bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedar-remove-from-bundle.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-cedar-remove-from-bundle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAIlC,KAAK,gBAAgB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,CAAA;AAEhE;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CA6B9C;AAQD,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,EAAE,EAAE,MAAM;;SAS5E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
4
|
+
function cedarRemoveFromBundle() {
|
|
5
|
+
const apiPackageJsonPath = path.join(getPaths().api.base, "package.json");
|
|
6
|
+
const realtimeEnabled = fs.existsSync(apiPackageJsonPath) && fs.readFileSync(apiPackageJsonPath, "utf-8").includes("@cedarjs/realtime");
|
|
7
|
+
const modulesToExclude = [
|
|
8
|
+
{
|
|
9
|
+
id: /@cedarjs\/router\/dist\/splash-page/,
|
|
10
|
+
exportNames: ["SplashPage"]
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
if (!realtimeEnabled) {
|
|
14
|
+
modulesToExclude.push({
|
|
15
|
+
id: /@cedarjs\/web\/dist\/apollo\/sseLink/
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
name: "remove-from-bundle",
|
|
20
|
+
apply: "build",
|
|
21
|
+
load: (id) => {
|
|
22
|
+
return excludeOnMatch(modulesToExclude, id);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function generateModuleWithExports(exportNames) {
|
|
27
|
+
return {
|
|
28
|
+
code: `export default {}; ${exportNames.map((name) => `export const ${name} = undefined;`).join("\n")}`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function excludeOnMatch(modulesToExclude, id) {
|
|
32
|
+
const moduleToExclude = modulesToExclude.find((module) => module.id.test(id));
|
|
33
|
+
if (moduleToExclude) {
|
|
34
|
+
return generateModuleWithExports(moduleToExclude.exportNames || []);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
cedarRemoveFromBundle,
|
|
40
|
+
excludeOnMatch
|
|
41
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { PluginOption } from 'vite';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
3
|
* This is a vite plugin to load and transform JS files as JSX.
|
|
5
|
-
*
|
|
6
4
|
*/
|
|
7
|
-
export declare function
|
|
5
|
+
export declare function cedarTransformJsAsJsx(): PluginOption;
|
|
8
6
|
//# sourceMappingURL=vite-plugin-jsx-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-jsx-loader.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-jsx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC
|
|
1
|
+
{"version":3,"file":"vite-plugin-jsx-loader.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-jsx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAGxC;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,YAAY,CAgBpD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { transformWithEsbuild } from "vite";
|
|
2
|
-
function
|
|
2
|
+
function cedarTransformJsAsJsx() {
|
|
3
3
|
return {
|
|
4
4
|
name: "transform-js-files-as-jsx",
|
|
5
5
|
async transform(code, id) {
|
|
@@ -14,5 +14,5 @@ function handleJsAsJsx() {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
cedarTransformJsAsJsx
|
|
18
18
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-merged-config.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-merged-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAMlC,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
2
|
+
import { getMergedConfig } from "../lib/getMergedConfig.js";
|
|
3
|
+
function cedarMergedConfig() {
|
|
4
|
+
const rwPaths = getPaths();
|
|
5
|
+
const rwConfig = getConfig();
|
|
6
|
+
return {
|
|
7
|
+
name: "vite-plugin-cedar",
|
|
8
|
+
// Using the config hook here lets us modify the config but returning
|
|
9
|
+
// plugins will **not** work
|
|
10
|
+
config: getMergedConfig(rwConfig, rwPaths)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
cedarMergedConfig
|
|
15
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* until it becomes stable.
|
|
3
|
+
* Temporary plugin, that swaps the ApolloProvider import with the Suspense
|
|
4
|
+
* enabled one, until it becomes stable.
|
|
6
5
|
*
|
|
7
6
|
* import { RedwoodApolloProvider } from "@cedarjs/web/apollo" ->
|
|
8
7
|
* import { RedwoodApolloProvider } from "@cedarjs/web/dist/apollo/suspense"
|
|
9
|
-
*
|
|
10
8
|
*/
|
|
11
|
-
export declare function
|
|
9
|
+
export declare function cedarSwapApolloProvider(): Plugin | undefined;
|
|
12
10
|
//# sourceMappingURL=vite-plugin-swap-apollo-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-swap-apollo-provider.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-swap-apollo-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"vite-plugin-swap-apollo-provider.d.ts","sourceRoot":"","sources":["../../src/plugins/vite-plugin-swap-apollo-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,GAAG,SAAS,CAoB5D"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
2
|
+
function cedarSwapApolloProvider() {
|
|
3
|
+
const streamingEnabled = getConfig().experimental.streamingSsr.enabled;
|
|
4
|
+
if (!streamingEnabled) {
|
|
5
|
+
return void 0;
|
|
6
|
+
}
|
|
2
7
|
return {
|
|
3
8
|
name: "redwood-swap-apollo-provider",
|
|
4
9
|
async transform(code, id) {
|
|
@@ -13,5 +18,5 @@ function swapApolloProvider() {
|
|
|
13
18
|
};
|
|
14
19
|
}
|
|
15
20
|
export {
|
|
16
|
-
|
|
21
|
+
cedarSwapApolloProvider
|
|
17
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Vite configuration package for CedarJS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,10 +33,6 @@
|
|
|
33
33
|
"import": "./dist/build/build.js",
|
|
34
34
|
"default": "./dist/cjs/build/build.js"
|
|
35
35
|
},
|
|
36
|
-
"./plugins": {
|
|
37
|
-
"import": "./dist/plugins/index.js",
|
|
38
|
-
"default": "./dist/cjs/plugins/index.js"
|
|
39
|
-
},
|
|
40
36
|
"./bins/rw-vite-build.mjs": "./bins/rw-vite-build.mjs"
|
|
41
37
|
},
|
|
42
38
|
"bin": {
|
|
@@ -63,13 +59,13 @@
|
|
|
63
59
|
"@babel/generator": "7.27.5",
|
|
64
60
|
"@babel/parser": "7.27.5",
|
|
65
61
|
"@babel/traverse": "7.27.4",
|
|
66
|
-
"@cedarjs/auth": "0.
|
|
67
|
-
"@cedarjs/babel-config": "0.
|
|
68
|
-
"@cedarjs/cookie-jar": "0.
|
|
69
|
-
"@cedarjs/internal": "0.
|
|
70
|
-
"@cedarjs/project-config": "0.
|
|
71
|
-
"@cedarjs/server-store": "0.
|
|
72
|
-
"@cedarjs/web": "0.
|
|
62
|
+
"@cedarjs/auth": "0.5.0",
|
|
63
|
+
"@cedarjs/babel-config": "0.5.0",
|
|
64
|
+
"@cedarjs/cookie-jar": "0.5.0",
|
|
65
|
+
"@cedarjs/internal": "0.5.0",
|
|
66
|
+
"@cedarjs/project-config": "0.5.0",
|
|
67
|
+
"@cedarjs/server-store": "0.5.0",
|
|
68
|
+
"@cedarjs/web": "0.5.0",
|
|
73
69
|
"@swc/core": "1.12.1",
|
|
74
70
|
"@vitejs/plugin-react": "4.3.4",
|
|
75
71
|
"@whatwg-node/fetch": "0.9.21",
|
|
@@ -89,14 +85,14 @@
|
|
|
89
85
|
"react": "18.3.1",
|
|
90
86
|
"react-server-dom-webpack": "19.0.0-rc-8269d55d-20240802",
|
|
91
87
|
"rimraf": "6.0.1",
|
|
92
|
-
"vite": "5.4.
|
|
88
|
+
"vite": "5.4.19",
|
|
93
89
|
"vite-plugin-cjs-interop": "2.2.0",
|
|
94
90
|
"vite-plugin-node-polyfills": "0.23.0",
|
|
95
91
|
"ws": "8.18.0",
|
|
96
92
|
"yargs-parser": "21.1.1"
|
|
97
93
|
},
|
|
98
94
|
"devDependencies": {
|
|
99
|
-
"@arethetypeswrong/cli": "0.18.
|
|
95
|
+
"@arethetypeswrong/cli": "0.18.2",
|
|
100
96
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|
|
101
97
|
"@types/busboy": "^1",
|
|
102
98
|
"@types/express": "4",
|
|
@@ -109,12 +105,12 @@
|
|
|
109
105
|
"memfs": "4.17.2",
|
|
110
106
|
"publint": "0.3.12",
|
|
111
107
|
"rollup": "4.24.0",
|
|
112
|
-
"tsx": "4.
|
|
108
|
+
"tsx": "4.20.3",
|
|
113
109
|
"typescript": "5.6.2",
|
|
114
110
|
"vitest": "3.2.4"
|
|
115
111
|
},
|
|
116
112
|
"publishConfig": {
|
|
117
113
|
"access": "public"
|
|
118
114
|
},
|
|
119
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "0543d358657163ade6edaf1c7308fb9b35a889bc"
|
|
120
116
|
}
|
|
@@ -1,43 +0,0 @@
|
|
|
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 plugins_exports = {};
|
|
20
|
-
__export(plugins_exports, {
|
|
21
|
-
cedarCellTransform: () => import_vite_plugin_cedar_cell.cedarCellTransform,
|
|
22
|
-
cedarjsDirectoryNamedImportPlugin: () => import_vite_plugin_cedarjs_directory_named_import.cedarjsDirectoryNamedImportPlugin,
|
|
23
|
-
cedarjsJobPathInjectorPlugin: () => import_vite_plugin_cedarjs_job_path_injector.cedarjsJobPathInjectorPlugin,
|
|
24
|
-
handleJsAsJsx: () => import_vite_plugin_jsx_loader.handleJsAsJsx,
|
|
25
|
-
removeFromBundle: () => import_vite_plugin_remove_from_bundle.removeFromBundle,
|
|
26
|
-
swapApolloProvider: () => import_vite_plugin_swap_apollo_provider.swapApolloProvider
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(plugins_exports);
|
|
29
|
-
var import_vite_plugin_cedar_cell = require("./vite-plugin-cedar-cell.js");
|
|
30
|
-
var import_vite_plugin_cedarjs_directory_named_import = require("./vite-plugin-cedarjs-directory-named-import.js");
|
|
31
|
-
var import_vite_plugin_cedarjs_job_path_injector = require("./vite-plugin-cedarjs-job-path-injector.js");
|
|
32
|
-
var import_vite_plugin_jsx_loader = require("./vite-plugin-jsx-loader.js");
|
|
33
|
-
var import_vite_plugin_remove_from_bundle = require("./vite-plugin-remove-from-bundle.js");
|
|
34
|
-
var import_vite_plugin_swap_apollo_provider = require("./vite-plugin-swap-apollo-provider.js");
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
cedarCellTransform,
|
|
38
|
-
cedarjsDirectoryNamedImportPlugin,
|
|
39
|
-
cedarjsJobPathInjectorPlugin,
|
|
40
|
-
handleJsAsJsx,
|
|
41
|
-
removeFromBundle,
|
|
42
|
-
swapApolloProvider
|
|
43
|
-
});
|