@wix/origami-site 1.0.13 → 1.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/origami-site",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Runs an exported Wix origami site: file-based routing, Wix dynamic pages, popups and build checks. Use with @wix/origami-site-astro or @wix/origami-site-express.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@wix/origami-types": "1.4.2",
|
|
49
49
|
"@wix/builder-error-pages": "^1.1.6",
|
|
50
50
|
"@wix/builder-piler-components": "^1.6.7",
|
|
51
|
-
"@wix/origami-transforms": "0.1.
|
|
51
|
+
"@wix/origami-transforms": "0.1.26",
|
|
52
52
|
"@babel/parser": "^7.25.0",
|
|
53
53
|
"@wix/system-core-components": "^1.3.10",
|
|
54
54
|
"@wix/origami-services": "1.2.4",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"optional": true
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
-
"falconPackageHash": "
|
|
96
|
+
"falconPackageHash": "0719bd471fec90c60511bd0136151ec3ed864981446b865cc620ce4b"
|
|
97
97
|
}
|
|
@@ -11,10 +11,14 @@ import {
|
|
|
11
11
|
|
|
12
12
|
// Companion app components and context providers skip the component wrapper server, so they arrive without its
|
|
13
13
|
// wrapping. Each `@site/site-code/<Name>` import resolves to a module that wraps the client entry registered as
|
|
14
|
-
// `companionApp.<Name>` the way the server wraps its components and providers, without the presets.
|
|
15
|
-
//
|
|
14
|
+
// `companionApp.<Name>` the way the server wraps its components and providers, without the presets. A function
|
|
15
|
+
// library's module re-exports its client entry, unwrapped, as the server's library wrapper does.
|
|
16
|
+
// TypeScript doesn't run this plugin: it resolves the same import through site-code's `package.json` `exports`, which
|
|
17
|
+
// this plugin keeps in step with the registrations.
|
|
16
18
|
const IMPORT = /^@site\/site-code\/([A-Za-z_$][\w$]*)$/
|
|
17
19
|
const PREFIX = '\0origami-companion:'
|
|
20
|
+
// The `exports` entry of an `@site/site-code/<Name>` import.
|
|
21
|
+
const COMPANION_EXPORT = /^\.\/[A-Za-z_$][\w$]*$/
|
|
18
22
|
|
|
19
23
|
/** @param {string} siteRoot */
|
|
20
24
|
export const companionComponents = siteRoot => {
|
|
@@ -68,6 +72,7 @@ export const companionComponents = siteRoot => {
|
|
|
68
72
|
// The wrapper comes from the registration file, so editing it reloads the module.
|
|
69
73
|
this.addWatchFile(module.registration.path)
|
|
70
74
|
const from = JSON.stringify(entry(module.registration))
|
|
75
|
+
if (module.registration.kind === 'functionLibrary') return `export * from ${from}`
|
|
71
76
|
const exported = exportedName(module.import)
|
|
72
77
|
const wrapped =
|
|
73
78
|
module.registration.kind === 'component' ? 'withInteractions(withOrigami(Raw))' : 'withOrigami(Raw)'
|
|
@@ -95,14 +100,19 @@ const exportedName = companionImport => {
|
|
|
95
100
|
const relativePath = (from, to) => relative(from, to).split(sep).join('/')
|
|
96
101
|
|
|
97
102
|
/**
|
|
98
|
-
* Writes site-code's `package.json` `exports`, as the export does, so a component or
|
|
99
|
-
* removed after the export type-checks with no manual entry.
|
|
100
|
-
*
|
|
103
|
+
* Writes site-code's `package.json` `exports`, as the export does, so a component, context or library added, renamed
|
|
104
|
+
* or removed after the export type-checks with no manual entry. Entries no page imports as `@site/site-code/<Name>`,
|
|
105
|
+
* such as `.`, are kept. import-site uploads the stored `exports`, not these.
|
|
106
|
+
* @param {string} appRoot @param {Record<string, string>} registered
|
|
101
107
|
*/
|
|
102
|
-
const writeExports = (appRoot,
|
|
108
|
+
const writeExports = (appRoot, registered) => {
|
|
103
109
|
const packagePath = resolve(appRoot, 'package.json')
|
|
104
110
|
if (!existsSync(packagePath)) return
|
|
105
111
|
const packageJson = JSON.parse(readFileSync(packagePath, 'utf8'))
|
|
112
|
+
// A string `exports` is the package's `.` entry.
|
|
113
|
+
const current = typeof packageJson.exports === 'string' ? { '.': packageJson.exports } : (packageJson.exports ?? {})
|
|
114
|
+
const others = Object.entries(current).filter(([key]) => !COMPANION_EXPORT.test(key))
|
|
115
|
+
const exports = { ...Object.fromEntries(others), ...registered }
|
|
106
116
|
if (JSON.stringify(exports) === JSON.stringify(packageJson.exports)) return
|
|
107
117
|
writeFileSync(packagePath, `${JSON.stringify({ ...packageJson, exports }, null, 2)}\n`)
|
|
108
118
|
}
|