@modern-js/uni-builder 2.65.4 → 2.65.5

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.
@@ -0,0 +1 @@
1
+ export = any;
@@ -0,0 +1,14 @@
1
+ (()=>{var __webpack_modules__={920:(module,__unused_webpack_exports,__nccwpck_require__)=>{const path=__nccwpck_require__(928);const fs=__nccwpck_require__(896);const os=__nccwpck_require__(857);const url=__nccwpck_require__(16);const fsReadFileAsync=fs.promises.readFile;function getDefaultSearchPlaces(e,t){return["package.json",`.${e}rc.json`,`.${e}rc.js`,`.${e}rc.cjs`,...t?[]:[`.${e}rc.mjs`],`.config/${e}rc`,`.config/${e}rc.json`,`.config/${e}rc.js`,`.config/${e}rc.cjs`,...t?[]:[`.config/${e}rc.mjs`],`${e}.config.js`,`${e}.config.cjs`,...t?[]:[`${e}.config.mjs`]]}function parentDir(e){return path.dirname(e)||path.sep}const jsonLoader=(e,t)=>JSON.parse(t);const requireFunc=true?eval("require"):0;const defaultLoadersSync=Object.freeze({".js":requireFunc,".json":requireFunc,".cjs":requireFunc,noExt:jsonLoader});module.exports.defaultLoadersSync=defaultLoadersSync;const dynamicImport=async e=>{try{const t=url.pathToFileURL(e).href;const r=await import(t);return r.default}catch(t){try{return requireFunc(e)}catch(e){if(e.code==="ERR_REQUIRE_ESM"||e instanceof SyntaxError&&e.toString().includes("Cannot use import statement outside a module")){throw t}throw e}}};const defaultLoaders=Object.freeze({".js":dynamicImport,".mjs":dynamicImport,".cjs":dynamicImport,".json":jsonLoader,noExt:jsonLoader});module.exports.defaultLoaders=defaultLoaders;function getOptions(e,t,r){const n={stopDir:os.homedir(),searchPlaces:getDefaultSearchPlaces(e,r),ignoreEmptySearchPlaces:true,cache:true,transform:e=>e,packageProp:[e],...t,loaders:{...r?defaultLoadersSync:defaultLoaders,...t.loaders}};n.searchPlaces.forEach((e=>{const t=path.extname(e)||"noExt";const r=n.loaders[t];if(!r){throw new Error(`Missing loader for extension "${e}"`)}if(typeof r!=="function"){throw new Error(`Loader for extension "${e}" is not a function: Received ${typeof r}.`)}}));return n}function getPackageProp(e,t){if(typeof e==="string"&&e in t)return t[e];return(Array.isArray(e)?e:e.split(".")).reduce(((e,t)=>e===undefined?e:e[t]),t)||null}function validateFilePath(e){if(!e)throw new Error("load must pass a non-empty string")}function validateLoader(e,t){if(!e)throw new Error(`No loader specified for extension "${t}"`);if(typeof e!=="function")throw new Error("loader is not a function")}const makeEmplace=e=>(t,r,n)=>{if(e)t.set(r,n);return n};module.exports.lilconfig=function lilconfig(e,t){const{ignoreEmptySearchPlaces:r,loaders:n,packageProp:o,searchPlaces:a,stopDir:s,transform:c,cache:i}=getOptions(e,t??{},false);const f=new Map;const l=new Map;const u=makeEmplace(i);return{async search(e=process.cwd()){const t={config:null,filepath:""};const l=new Set;let u=e;e:while(true){if(i){const e=f.get(u);if(e!==undefined){for(const t of l)f.set(t,e);return e}l.add(u)}for(const e of a){const a=path.join(u,e);try{await fs.promises.access(a)}catch{continue}const s=String(await fsReadFileAsync(a));const c=path.extname(e)||"noExt";const i=n[c];if(e==="package.json"){const e=await i(a,s);const r=getPackageProp(o,e);if(r!=null){t.config=r;t.filepath=a;break e}continue}const f=s.trim()==="";if(f&&r)continue;if(f){t.isEmpty=true;t.config=undefined}else{validateLoader(i,c);t.config=await i(a,s)}t.filepath=a;break e}if(u===s||u===parentDir(u))break e;u=parentDir(u)}const p=t.filepath===""&&t.config===null?c(null):c(t);if(i){for(const e of l)f.set(e,p)}return p},async load(e){validateFilePath(e);const t=path.resolve(process.cwd(),e);if(i&&l.has(t)){return l.get(t)}const{base:a,ext:s}=path.parse(t);const f=s||"noExt";const p=n[f];validateLoader(p,f);const d=String(await fsReadFileAsync(t));if(a==="package.json"){const e=await p(t,d);return u(l,t,c({config:getPackageProp(o,e),filepath:t}))}const _={config:null,filepath:t};const g=d.trim()==="";if(g&&r)return u(l,t,c({config:undefined,filepath:t,isEmpty:true}));_.config=g?undefined:await p(t,d);return u(l,t,c(g?{..._,isEmpty:g,config:undefined}:_))},clearLoadCache(){if(i)l.clear()},clearSearchCache(){if(i)f.clear()},clearCaches(){if(i){l.clear();f.clear()}}}};module.exports.lilconfigSync=function lilconfigSync(e,t){const{ignoreEmptySearchPlaces:r,loaders:n,packageProp:o,searchPlaces:a,stopDir:s,transform:c,cache:i}=getOptions(e,t??{},true);const f=new Map;const l=new Map;const u=makeEmplace(i);return{search(e=process.cwd()){const t={config:null,filepath:""};const l=new Set;let u=e;e:while(true){if(i){const e=f.get(u);if(e!==undefined){for(const t of l)f.set(t,e);return e}l.add(u)}for(const e of a){const a=path.join(u,e);try{fs.accessSync(a)}catch{continue}const s=path.extname(e)||"noExt";const c=n[s];const i=String(fs.readFileSync(a));if(e==="package.json"){const e=c(a,i);const r=getPackageProp(o,e);if(r!=null){t.config=r;t.filepath=a;break e}continue}const f=i.trim()==="";if(f&&r)continue;if(f){t.isEmpty=true;t.config=undefined}else{validateLoader(c,s);t.config=c(a,i)}t.filepath=a;break e}if(u===s||u===parentDir(u))break e;u=parentDir(u)}const p=t.filepath===""&&t.config===null?c(null):c(t);if(i){for(const e of l)f.set(e,p)}return p},load(e){validateFilePath(e);const t=path.resolve(process.cwd(),e);if(i&&l.has(t)){return l.get(t)}const{base:a,ext:s}=path.parse(t);const f=s||"noExt";const p=n[f];validateLoader(p,f);const d=String(fs.readFileSync(t));if(a==="package.json"){const e=p(t,d);return c({config:getPackageProp(o,e),filepath:t})}const _={config:null,filepath:t};const g=d.trim()==="";if(g&&r)return u(l,t,c({filepath:t,config:undefined,isEmpty:true}));_.config=g?undefined:p(t,d);return u(l,t,c(g?{..._,isEmpty:g,config:undefined}:_))},clearLoadCache(){if(i)l.clear()},clearSearchCache(){if(i)f.clear()},clearCaches(){if(i){l.clear();f.clear()}}}}},109:(e,t,r)=>{const{resolve:n}=r(760);const o=r(920);const a=r(471);const s=r(697);const c=r(257);const interopRequireDefault=e=>e&&e.__esModule?e:{default:e};async function processResult(e,t){let r=t.filepath||"";let n=interopRequireDefault(t.config).default||{};if(typeof n==="function"){n=n(e)}else{n=Object.assign({},n,e)}if(!n.plugins){n.plugins=[]}let o={file:r,options:await a(n,r),plugins:await s(n,r)};delete n.plugins;return o}function createContext(e){e=Object.assign({cwd:process.cwd(),env:process.env.NODE_ENV},e);if(!e.env){process.env.NODE_ENV="development"}return e}async function loader(e){return c(e)}let i;async function yamlLoader(e,t){if(!i){try{i=await Promise.resolve().then(r.t.bind(r,160,23))}catch(e){throw new Error(`'yaml' is required for the YAML configuration files. Make sure it is installed\nError: ${e.message}`)}}return i.parse(t)}const withLoaders=(e={})=>{let t="postcss";return{...e,loaders:{...e.loaders,".cjs":loader,".cts":loader,".js":loader,".mjs":loader,".mts":loader,".ts":loader,".yaml":yamlLoader,".yml":yamlLoader},searchPlaces:[...e.searchPlaces||[],"package.json",`.${t}rc`,`.${t}rc.json`,`.${t}rc.yaml`,`.${t}rc.yml`,`.${t}rc.ts`,`.${t}rc.cts`,`.${t}rc.mts`,`.${t}rc.js`,`.${t}rc.cjs`,`.${t}rc.mjs`,`${t}.config.ts`,`${t}.config.cts`,`${t}.config.mts`,`${t}.config.js`,`${t}.config.cjs`,`${t}.config.mjs`]}};function rc(e,t,r){e=createContext(e);t=t?n(t):process.cwd();return o.lilconfig("postcss",withLoaders(r)).search(t).then((r=>{if(!r){throw new Error(`No PostCSS Config found in: ${t}`)}return processResult(e,r)}))}
2
+ /**
3
+ * Autoload Config for PostCSS
4
+ *
5
+ * @author Michael Ciniawsky @michael-ciniawsky <michael.ciniawsky@gmail.com>
6
+ * @license MIT
7
+ *
8
+ * @module postcss-load-config
9
+ * @version 2.1.0
10
+ *
11
+ * @requires comsiconfig
12
+ * @requires ./options
13
+ * @requires ./plugins
14
+ */e.exports=rc},471:(e,t,r)=>{const n=r(257);async function options(e,t){if(e.parser&&typeof e.parser==="string"){try{e.parser=await n(e.parser,t)}catch(e){throw new Error(`Loading PostCSS Parser failed: ${e.message}\n\n(@${t})`)}}if(e.syntax&&typeof e.syntax==="string"){try{e.syntax=await n(e.syntax,t)}catch(e){throw new Error(`Loading PostCSS Syntax failed: ${e.message}\n\n(@${t})`)}}if(e.stringifier&&typeof e.stringifier==="string"){try{e.stringifier=await n(e.stringifier,t)}catch(e){throw new Error(`Loading PostCSS Stringifier failed: ${e.message}\n\n(@${t})`)}}return e}e.exports=options},697:(e,t,r)=>{const n=r(257);async function load(e,t,r){try{if(t===null||t===undefined||Object.keys(t).length===0){return await n(e,r)}else{return(await n(e,r))(t)}}catch(e){throw new Error(`Loading PostCSS Plugin failed: ${e.message}\n\n(@${r})`)}}async function plugins(e,t){let r=[];if(Array.isArray(e.plugins)){r=e.plugins.filter(Boolean)}else{r=Object.entries(e.plugins).filter((([,e])=>e!==false)).map((([e,r])=>load(e,r,t)));r=await Promise.all(r)}if(r.length&&r.length>0){r.forEach(((e,r)=>{if(e.default){e=e.default}if(e.postcss===true){e=e()}else if(e.postcss){e=e.postcss}if(!(typeof e==="object"&&Array.isArray(e.plugins)||typeof e==="object"&&e.postcssPlugin||typeof e==="function")){throw new TypeError(`Invalid PostCSS Plugin found at: plugins[${r}]\n\n(@${t})`)}}))}return r}e.exports=plugins},257:(e,t,r)=>{const{createRequire:n}=r(995);const{pathToFileURL:o}=r(136);const a=/\.[mc]?ts$/;let s;let c;let i=[];async function req(e,t=__filename){let r=n(t).resolve(e);try{return(await import(`${o(r)}?t=${Date.now()}`)).default}catch(e){if(!a.test(r)){throw e}}if(s===undefined){try{s=await import("tsx/cjs/api")}catch(e){i.push(e)}}if(s){let r=s.require(e,t);return r&&"__esModule"in r?r.default:r}if(c===undefined){try{c=(await import("jiti")).default}catch(e){i.push(e)}}if(c){return c(t,{interopDefault:true})(e)}throw new Error(`'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${i.map((e=>e.message)).join("\n")}`)}e.exports=req},896:e=>{"use strict";e.exports=require("fs")},995:e=>{"use strict";e.exports=require("node:module")},760:e=>{"use strict";e.exports=require("node:path")},136:e=>{"use strict";e.exports=require("node:url")},857:e=>{"use strict";e.exports=require("os")},928:e=>{"use strict";e.exports=require("path")},16:e=>{"use strict";e.exports=require("url")},160:e=>{"use strict";e.exports=require("yaml")}};var __webpack_module_cache__={};function __nccwpck_require__(e){var t=__webpack_module_cache__[e];if(t!==undefined){return t.exports}var r=__webpack_module_cache__[e]={exports:{}};var n=true;try{__webpack_modules__[e](r,r.exports,__nccwpck_require__);n=false}finally{if(n)delete __webpack_module_cache__[e]}return r.exports}(()=>{var e=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;var t;__nccwpck_require__.t=function(r,n){if(n&1)r=this(r);if(n&8)return r;if(typeof r==="object"&&r){if(n&4&&r.__esModule)return r;if(n&16&&typeof r.then==="function")return r}var o=Object.create(null);__nccwpck_require__.r(o);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=n&2&&r;typeof s=="object"&&!~t.indexOf(s);s=e(s)){Object.getOwnPropertyNames(s).forEach((e=>a[e]=()=>r[e]))}a["default"]=()=>r;__nccwpck_require__.d(o,a);return o}})();(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var __webpack_exports__=__nccwpck_require__(109);module.exports=__webpack_exports__})();
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright Michael Ciniawsky <michael.ciniawsky@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"postcss-load-config","author":"Michael Ciniawky <michael.ciniawsky@gmail.com>","version":"6.0.1","funding":[{"type":"opencollective","url":"https://opencollective.com/postcss/"},{"type":"github","url":"https://github.com/sponsors/ai"}],"license":"MIT","types":"index.d.ts"}
@@ -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 postcss_exports = {};
20
30
  __export(postcss_exports, {
@@ -23,6 +33,32 @@ __export(postcss_exports, {
23
33
  module.exports = __toCommonJS(postcss_exports);
24
34
  var import_utils = require("@modern-js/utils");
25
35
  var import_getCssSupport = require("../getCssSupport");
36
+ const userPostcssrcCache = /* @__PURE__ */ new Map();
37
+ const clonePostCSSConfig = (config) => ({
38
+ ...config,
39
+ plugins: config.plugins ? [
40
+ ...config.plugins
41
+ ] : void 0
42
+ });
43
+ async function loadUserPostcssrc(root) {
44
+ const cached = userPostcssrcCache.get(root);
45
+ if (cached) {
46
+ return clonePostCSSConfig(await cached);
47
+ }
48
+ const { default: postcssrc } = await Promise.resolve().then(() => __toESM(require("../../../compiled/postcss-load-config")));
49
+ const promise = postcssrc({}, root).catch((err) => {
50
+ var _err_message;
51
+ if ((_err_message = err.message) === null || _err_message === void 0 ? void 0 : _err_message.includes("No PostCSS Config found")) {
52
+ return {};
53
+ }
54
+ throw err;
55
+ });
56
+ userPostcssrcCache.set(root, promise);
57
+ return promise.then((config) => {
58
+ userPostcssrcCache.set(root, config);
59
+ return clonePostCSSConfig(config);
60
+ });
61
+ }
26
62
  const pluginPostcss = (options = {}) => ({
27
63
  name: "uni-builder:postcss-plugins",
28
64
  pre: [
@@ -30,7 +66,7 @@ const pluginPostcss = (options = {}) => ({
30
66
  ],
31
67
  setup(api) {
32
68
  const { autoprefixer } = options;
33
- api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig }) => {
69
+ api.modifyEnvironmentConfig(async (config, { mergeEnvironmentConfig }) => {
34
70
  var _config_output;
35
71
  if (config.output.target !== "web") {
36
72
  return config;
@@ -70,12 +106,17 @@ const pluginPostcss = (options = {}) => ({
70
106
  overrideBrowserslist: config.output.overrideBrowserslist
71
107
  }, autoprefixer))
72
108
  ].filter(Boolean);
109
+ const userOptions = await loadUserPostcssrc(api.context.rootPath);
73
110
  return mergeEnvironmentConfig(
74
111
  {
75
112
  tools: {
76
113
  postcss: {
77
114
  postcssOptions: {
78
- plugins
115
+ ...userOptions,
116
+ plugins: [
117
+ ...userOptions.plugins || [],
118
+ ...plugins
119
+ ]
79
120
  }
80
121
  }
81
122
  }
@@ -38,15 +38,7 @@ const hasExtension = (filePath) => {
38
38
  };
39
39
  class RspackRscClientPlugin {
40
40
  apply(compiler) {
41
- const {
42
- EntryPlugin,
43
- // AsyncDependenciesBlock,
44
- RuntimeGlobals,
45
- RuntimeModule,
46
- WebpackError,
47
- // dependencies: { ModuleDependency, NullDependency },
48
- sources: { RawSource }
49
- } = compiler.webpack;
41
+ const { EntryPlugin, RuntimeGlobals, RuntimeModule, WebpackError, sources: { RawSource } } = compiler.webpack;
50
42
  const ssrManifest = {
51
43
  moduleMap: {},
52
44
  moduleLoading: null,
@@ -76,14 +68,15 @@ class RspackRscClientPlugin {
76
68
  [
77
69
  ...this.clientReferencesMap.keys()
78
70
  ].forEach((resourcePath, index) => {
79
- const dependency = EntryPlugin.createDependency(resourcePath, {
80
- name: resourcePath
81
- });
82
71
  const entries = compilation.entries.entries();
83
72
  for (const [entryName, entry] of entries) {
73
+ const runtimeName = entry.options.runtime || entryName;
84
74
  if (hasExtension(entryName)) {
85
75
  continue;
86
76
  }
77
+ const dependency = EntryPlugin.createDependency(resourcePath, {
78
+ name: resourcePath
79
+ });
87
80
  promises.push(new Promise((resolve, reject) => {
88
81
  compilation.addInclude(compiler.context, dependency, {
89
82
  name: entryName
@@ -91,6 +84,7 @@ class RspackRscClientPlugin {
91
84
  if (error) {
92
85
  reject(error);
93
86
  } else {
87
+ compilation.moduleGraph.getExportsInfo(module2).setUsedInUnknownWay(runtimeName);
94
88
  this.dependencies.push(dependency);
95
89
  resolve(void 0);
96
90
  }
@@ -110,6 +104,7 @@ class RspackRscClientPlugin {
110
104
  if (error) {
111
105
  reject(error);
112
106
  } else {
107
+ compilation.moduleGraph.getExportsInfo(module2).setUsedInUnknownWay(void 0);
113
108
  this.dependencies.push(dependency);
114
109
  resolve(void 0);
115
110
  }
@@ -155,8 +150,12 @@ class RspackRscClientPlugin {
155
150
  });
156
151
  compilation.hooks.processAssets.tap(RspackRscClientPlugin.name, () => {
157
152
  const clientManifest = {};
158
- const { chunkGraph, moduleGraph, modules } = compilation;
159
- for (const module2 of modules) {
153
+ const { chunkGraph, moduleGraph } = compilation;
154
+ for (const dependency of this.dependencies) {
155
+ const module2 = moduleGraph.getModule(dependency);
156
+ if (!module2) {
157
+ continue;
158
+ }
160
159
  const resourcePath = module2.nameForCondition();
161
160
  const clientReferences = resourcePath ? this.clientReferencesMap.get(resourcePath) : void 0;
162
161
  if (clientReferences) {
@@ -1,6 +1,3 @@
1
- /**
2
- * The plugin is developing, ignore it now
3
- */
4
1
  import type Webpack from 'webpack';
5
2
  export interface RscServerPluginOptions {
6
3
  readonly serverManifestFilename?: string;
@@ -10,6 +7,10 @@ export interface ModuleExportsInfo {
10
7
  readonly moduleResource: string;
11
8
  readonly exportName: string;
12
9
  }
10
+ export interface EntryInfo {
11
+ readonly entryName: string;
12
+ readonly entryPath: string;
13
+ }
13
14
  export declare class RscServerPlugin {
14
15
  private clientReferencesMap;
15
16
  private serverReferencesMap;
@@ -18,6 +19,10 @@ export declare class RscServerPlugin {
18
19
  private entryPath2Name;
19
20
  private styles;
20
21
  constructor(options: RscServerPluginOptions);
22
+ private isValidModule;
23
+ private hasValidEntries;
24
+ private getEntryNameFromIssuer;
25
+ private createEntryFromIssuer;
21
26
  private findModuleEntries;
22
27
  apply(compiler: Webpack.Compiler): void;
23
28
  }
@@ -24,13 +24,28 @@ module.exports = __toCommonJS(rspack_rsc_server_plugin_exports);
24
24
  var import_common = require("../common");
25
25
  const resourcePath2Entries = /* @__PURE__ */ new Map();
26
26
  class RscServerPlugin {
27
+ isValidModule(module2) {
28
+ return Boolean(module2 === null || module2 === void 0 ? void 0 : module2.resource);
29
+ }
30
+ hasValidEntries(entries) {
31
+ return Boolean(entries && entries.length > 0);
32
+ }
33
+ getEntryNameFromIssuer(issuer) {
34
+ return issuer.resource ? this.entryPath2Name.get(issuer.resource) : void 0;
35
+ }
36
+ createEntryFromIssuer(issuer, entryName) {
37
+ return {
38
+ entryName,
39
+ entryPath: issuer.resource
40
+ };
41
+ }
27
42
  findModuleEntries(module2, compilation, resourcePath2Entries2, visited = /* @__PURE__ */ new Set()) {
28
- if (!(module2 === null || module2 === void 0 ? void 0 : module2.resource) || visited.has(module2.resource)) {
43
+ if (!this.isValidModule(module2) || visited.has(module2.resource)) {
29
44
  return [];
30
45
  }
31
46
  visited.add(module2.resource);
32
47
  const currentEntries = resourcePath2Entries2.get(module2.resource);
33
- if (currentEntries && (currentEntries === null || currentEntries === void 0 ? void 0 : currentEntries.length) > 0) {
48
+ if (this.hasValidEntries(currentEntries)) {
34
49
  return currentEntries;
35
50
  }
36
51
  const issuer = (0, import_common.findRootIssuer)(compilation.moduleGraph, module2);
@@ -38,32 +53,19 @@ class RscServerPlugin {
38
53
  return [];
39
54
  }
40
55
  const issuerEntries = this.findModuleEntries(issuer, compilation, resourcePath2Entries2, visited);
41
- if (issuerEntries.length > 0) {
56
+ if (this.hasValidEntries(issuerEntries)) {
42
57
  return issuerEntries;
43
58
  }
44
- if (issuer.resource) {
45
- const entryName = this.entryPath2Name.get(issuer.resource);
46
- if (entryName) {
47
- return [
48
- {
49
- entryName,
50
- entryPath: issuer.resource
51
- }
52
- ];
53
- }
59
+ const entryName = this.getEntryNameFromIssuer(issuer);
60
+ if (entryName) {
61
+ return [
62
+ this.createEntryFromIssuer(issuer, entryName)
63
+ ];
54
64
  }
55
65
  return [];
56
66
  }
57
67
  apply(compiler) {
58
- const {
59
- EntryPlugin,
60
- WebpackError,
61
- // dependencies: { NullDependency },
62
- // util: {
63
- // runtime: { getEntryRuntime },
64
- // },
65
- sources: { RawSource }
66
- } = compiler.webpack;
68
+ const { EntryPlugin, WebpackError, sources: { RawSource } } = compiler.webpack;
67
69
  const includeModule = async (compilation, resource, resourceEntryNames, layer) => {
68
70
  const entries = Array.from(compilation.entries.entries());
69
71
  if (entries.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/uni-builder",
3
- "version": "2.65.4",
3
+ "version": "2.65.5",
4
4
  "description": "Unified builder for Modern.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "@babel/preset-react": "^7.22.15",
31
31
  "@babel/types": "^7.26.0",
32
32
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
33
- "@rsbuild/core": "1.2.18",
33
+ "@rsbuild/core": "1.2.19",
34
34
  "@rsbuild/plugin-assets-retry": "1.2.1",
35
35
  "@rsbuild/plugin-babel": "1.0.4",
36
36
  "@rsbuild/plugin-check-syntax": "1.3.0",
@@ -61,6 +61,7 @@
61
61
  "glob": "^9.3.5",
62
62
  "html-minifier-terser": "^7.2.0",
63
63
  "html-webpack-plugin": "5.6.3",
64
+ "jiti": "1.21.7",
64
65
  "lodash": "^4.17.21",
65
66
  "magic-string": "0.30.17",
66
67
  "picocolors": "^1.0.1",
@@ -79,9 +80,9 @@
79
80
  "ts-loader": "9.4.4",
80
81
  "webpack": "^5.98.0",
81
82
  "webpack-subresource-integrity": "5.1.0",
82
- "@modern-js/babel-preset": "2.65.4",
83
- "@modern-js/flight-server-transform-plugin": "2.65.4",
84
- "@modern-js/utils": "2.65.4"
83
+ "@modern-js/babel-preset": "2.65.5",
84
+ "@modern-js/flight-server-transform-plugin": "2.65.5",
85
+ "@modern-js/utils": "2.65.5"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@rsbuild/plugin-webpack-swc": "1.0.12",
@@ -92,13 +93,12 @@
92
93
  "react-dom": "^18.2.0",
93
94
  "terser": "^5.31.1",
94
95
  "typescript": "^5.3.0",
95
- "@modern-js/types": "2.65.4",
96
- "@scripts/build": "2.65.4",
97
- "@scripts/vitest-config": "2.65.4"
96
+ "@modern-js/types": "2.65.5",
97
+ "@scripts/build": "2.65.5",
98
+ "@scripts/vitest-config": "2.65.5"
98
99
  },
99
100
  "publishConfig": {
100
101
  "access": "public",
101
- "provenance": true,
102
102
  "registry": "https://registry.npmjs.org/"
103
103
  },
104
104
  "scripts": {