@ecopages/react 0.7.0 → 0.8.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React integration for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -123,16 +123,16 @@
|
|
|
123
123
|
"directory": "packages/integrations/react"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
|
-
"@ecopages/core": "0.
|
|
126
|
+
"@ecopages/core": "0.8.0",
|
|
127
127
|
"@types/react": "^19",
|
|
128
128
|
"@types/react-dom": "^19",
|
|
129
129
|
"react": "^19",
|
|
130
130
|
"react-dom": "^19"
|
|
131
131
|
},
|
|
132
132
|
"dependencies": {
|
|
133
|
-
"@ecopages/file-system": "0.
|
|
133
|
+
"@ecopages/file-system": "0.8.0",
|
|
134
134
|
"@ecopages/logger": "^0.2.3",
|
|
135
|
-
"@ecopages/mdx": "0.
|
|
135
|
+
"@ecopages/mdx": "0.8.0",
|
|
136
136
|
"@mdx-js/mdx": "^3.1.1",
|
|
137
137
|
"oxc-parser": "^0.141.0"
|
|
138
138
|
}
|
|
@@ -250,6 +250,19 @@ function getForeignJsxReach(context, projectRoot, isForeignFile) {
|
|
|
250
250
|
}
|
|
251
251
|
return context.foreignJsxReach;
|
|
252
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* The file itself when it is a browser entry of the build that no React entry file claims.
|
|
255
|
+
*
|
|
256
|
+
* @remarks
|
|
257
|
+
* The import scan records only files an entry imports, so a foreign file that is bundled as its own entry, such
|
|
258
|
+
* as a Radiant script, is absent from it. Without this it would count as a file the scan did not find and keep
|
|
259
|
+
* React's override.
|
|
260
|
+
*/
|
|
261
|
+
function findForeignEntry(context, filePath) {
|
|
262
|
+
const entryFiles = new Set([...context.entrypointFiles].map(toRealPath));
|
|
263
|
+
const reactEntryFiles = new Set([...getReactEntrypointFiles(context)].map(toRealPath));
|
|
264
|
+
return entryFiles.has(filePath) && !reactEntryFiles.has(filePath) ? filePath : undefined;
|
|
265
|
+
}
|
|
253
266
|
/**
|
|
254
267
|
* Scope for React's foreign-JSX override: a file another JSX Integration owns gets React's JSX runtime only when
|
|
255
268
|
* a React entry file reaches it.
|
|
@@ -269,13 +282,15 @@ export function createForeignJsxScope(options) {
|
|
|
269
282
|
return true;
|
|
270
283
|
const reach = getForeignJsxReach(context, options.projectRoot, isForeignFile);
|
|
271
284
|
const filePath = toRealPath(sourcePath);
|
|
272
|
-
const otherEntry = reach.others.get(filePath);
|
|
285
|
+
const otherEntry = reach.others.get(filePath) ?? findForeignEntry(context, filePath);
|
|
273
286
|
if (otherEntry === undefined)
|
|
274
287
|
return true;
|
|
275
288
|
if (!reach.react.has(filePath))
|
|
276
289
|
return false;
|
|
277
|
-
|
|
278
|
-
`
|
|
290
|
+
const importedBy = otherEntry === filePath
|
|
291
|
+
? `is itself a browser entry and ${options.hostIntegrationName} browser entries import it`
|
|
292
|
+
: `that both ${options.hostIntegrationName} browser entries and another browser entry (${otherEntry}) import`;
|
|
293
|
+
throw new Error(`[ecopages] ${filePath} is a ${owner} file ${importedBy}. ${options.hostIntegrationName} compiles it with its ` +
|
|
279
294
|
`own JSX runtime and ${owner} with its runtime, but one module has one compiled form. Import it ` +
|
|
280
295
|
`from one of them only.`);
|
|
281
296
|
};
|