@vitejs/plugin-rsc 0.4.14 → 0.4.15
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/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./dist-DEF94lDJ.js";
|
|
2
2
|
import "./plugin-CZbI4rhS.js";
|
|
3
|
-
import { transformHoistInlineDirective, vitePluginRsc } from "./plugin-
|
|
3
|
+
import { transformHoistInlineDirective, vitePluginRsc } from "./plugin-_STtCzuL.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-tGuLT8PD.js";
|
|
6
6
|
import "./vite-utils-Vzd7cqfv.js";
|
|
@@ -13,7 +13,7 @@ import { createRequestListener } from "@mjackson/node-fetch-server";
|
|
|
13
13
|
import * as esModuleLexer from "es-module-lexer";
|
|
14
14
|
import MagicString from "magic-string";
|
|
15
15
|
import { defaultServerConditions, isCSSRequest, normalizePath, parseAstAsync } from "vite";
|
|
16
|
-
import { crawlFrameworkPkgs } from "vitefu";
|
|
16
|
+
import { crawlFrameworkPkgs, findClosestPkgJsonPath } from "vitefu";
|
|
17
17
|
import { walk } from "estree-walker";
|
|
18
18
|
import { analyze, extract_names } from "periscopic";
|
|
19
19
|
|
|
@@ -798,9 +798,30 @@ globalThis.AsyncLocalStorage = __viteRscAyncHooks.AsyncLocalStorage;
|
|
|
798
798
|
...vitePluginFindSourceMapURL(),
|
|
799
799
|
...vitePluginRscCss({ rscCssTransform: rscPluginOptions.rscCssTransform }),
|
|
800
800
|
...rscPluginOptions.validateImports !== false ? [validateImportPlugin()] : [],
|
|
801
|
-
scanBuildStripPlugin()
|
|
801
|
+
scanBuildStripPlugin(),
|
|
802
|
+
detectNonOptimizedCjsPlugin()
|
|
802
803
|
];
|
|
803
804
|
}
|
|
805
|
+
function detectNonOptimizedCjsPlugin() {
|
|
806
|
+
return {
|
|
807
|
+
name: "rsc:detect-non-optimized-cjs",
|
|
808
|
+
apply: "serve",
|
|
809
|
+
async transform(code, id) {
|
|
810
|
+
if (id.includes("/node_modules/") && !id.startsWith(this.environment.config.cacheDir) && /\b(require|exports)\b/.test(code)) {
|
|
811
|
+
id = parseIdQuery(id).filename;
|
|
812
|
+
let isEsm = id.endsWith(".mjs");
|
|
813
|
+
if (id.endsWith(".js")) {
|
|
814
|
+
const pkgJsonPath = await findClosestPkgJsonPath(path.dirname(id));
|
|
815
|
+
if (pkgJsonPath) {
|
|
816
|
+
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
817
|
+
isEsm = pkgJson.type === "module";
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
if (!isEsm) this.warn(`[vite-rsc] found non-optimized CJS dependency in '${this.environment.name}' environment. It is recommended to manually add the dependency to 'environments.${this.environment.name}.optimizeDeps.include'.`);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
}
|
|
804
825
|
function scanBuildStripPlugin() {
|
|
805
826
|
return {
|
|
806
827
|
name: "rsc:scan-strip",
|
|
@@ -1267,7 +1288,7 @@ function vitePluginRscCss(rscCssOptions) {
|
|
|
1267
1288
|
};
|
|
1268
1289
|
}
|
|
1269
1290
|
function getRscCssTransformFilter({ id, code }) {
|
|
1270
|
-
const { query } = parseIdQuery(id);
|
|
1291
|
+
const { filename, query } = parseIdQuery(id);
|
|
1271
1292
|
if ("vite-rsc-css-export" in query) {
|
|
1272
1293
|
const value = query["vite-rsc-css-export"];
|
|
1273
1294
|
if (value) {
|
|
@@ -1278,8 +1299,8 @@ function vitePluginRscCss(rscCssOptions) {
|
|
|
1278
1299
|
}
|
|
1279
1300
|
const options = rscCssOptions?.rscCssTransform;
|
|
1280
1301
|
if (options === false) return false;
|
|
1281
|
-
if (options?.filter && !options.filter(
|
|
1282
|
-
if (
|
|
1302
|
+
if (options?.filter && !options.filter(filename)) return false;
|
|
1303
|
+
if (!/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)\b/.test(code) || !/\.[tj]sx?$/.test(filename)) return false;
|
|
1283
1304
|
const result = esModuleLexer.parse(code);
|
|
1284
1305
|
if (!result[0].some((i) => i.t === 1 && i.n && isCSSRequest(i.n))) return false;
|
|
1285
1306
|
return (_name, meta) => !!(meta.isFunction && meta.declName && /^[A-Z]/.test(meta.declName) || meta.defaultExportIdentifierName && /^[A-Z]/.test(meta.defaultExportIdentifierName));
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./dist-DEF94lDJ.js";
|
|
2
2
|
import "./plugin-CZbI4rhS.js";
|
|
3
|
-
import { __fix_cloudflare, findSourceMapURL, transformRscCssExport, vitePluginFindSourceMapURL, vitePluginRsc, vitePluginRscCss } from "./plugin-
|
|
3
|
+
import { __fix_cloudflare, findSourceMapURL, transformRscCssExport, vitePluginFindSourceMapURL, vitePluginRsc, vitePluginRscCss } from "./plugin-_STtCzuL.js";
|
|
4
4
|
import "./encryption-utils-BDwwcMVT.js";
|
|
5
5
|
import "./rpc-tGuLT8PD.js";
|
|
6
6
|
import "./vite-utils-Vzd7cqfv.js";
|