@shopify/hydrogen 0.10.0-experimental.0 → 0.10.0-experimental.1
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/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/package.json +3 -2
- package/vendor/react-server-dom-vite/LICENSE +21 -0
- package/vendor/react-server-dom-vite/README.md +5 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +189 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.development.server.js +1030 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.browser.production.min.server.js +429 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.development.server.js +1052 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-writer.node.production.min.server.js +445 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.development.js +620 -0
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite.production.min.js +252 -0
- package/vendor/react-server-dom-vite/esm/package.json +3 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +81 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +183 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.browser.server.js +1013 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-writer.node.server.js +1031 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite.js +610 -0
- package/vendor/react-server-dom-vite/index.js +7 -0
- package/vendor/react-server-dom-vite/package.json +68 -0
- package/vendor/react-server-dom-vite/plugin.js +3 -0
- package/vendor/react-server-dom-vite/writer.browser.server.js +7 -0
- package/vendor/react-server-dom-vite/writer.node.server.js +7 -0
package/dist/esnext/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.10.0-experimental.
|
|
1
|
+
export declare const LIB_VERSION = "0.10.0-experimental.1";
|
package/dist/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '0.10.0-experimental.
|
|
1
|
+
export const LIB_VERSION = '0.10.0-experimental.1';
|
package/package.json
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=14"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.10.0-experimental.
|
|
10
|
+
"version": "0.10.0-experimental.1",
|
|
11
11
|
"description": "Modern custom Shopify storefronts",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "dist/esnext/index.js",
|
|
14
14
|
"types": "dist/esnext/index.d.ts",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
+
"vendor",
|
|
17
18
|
"plugin.js",
|
|
18
19
|
"plugin.d.ts",
|
|
19
20
|
"entry-server.js",
|
|
@@ -104,5 +105,5 @@
|
|
|
104
105
|
"react-helmet-async": "^1.2.2",
|
|
105
106
|
"vite-plugin-inspect": "^0.3.6"
|
|
106
107
|
},
|
|
107
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "68a73366aa6466e6641e8f3aeb44d0ef7dba7eea"
|
|
108
109
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, 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,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/** @license React vundefined
|
|
2
|
+
* react-server-dom-vite-plugin.js
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
var esModuleLexer = require('es-module-lexer');
|
|
15
|
+
var vite = require('vite');
|
|
16
|
+
var fs = require('fs');
|
|
17
|
+
var path = require('path');
|
|
18
|
+
|
|
19
|
+
// $FlowFixMe[module-missing]
|
|
20
|
+
function ReactFlightVitePlugin() {
|
|
21
|
+
var _ref =
|
|
22
|
+
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
23
|
+
_ref$clientComponentP = _ref.clientComponentPaths,
|
|
24
|
+
clientComponentPaths =
|
|
25
|
+
_ref$clientComponentP === void 0 ? [] : _ref$clientComponentP,
|
|
26
|
+
_ref$isServerComponen = _ref.isServerComponentImporterAllowed,
|
|
27
|
+
isServerComponentImporterAllowed =
|
|
28
|
+
_ref$isServerComponen === void 0
|
|
29
|
+
? function (importer) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
: _ref$isServerComponen;
|
|
33
|
+
|
|
34
|
+
var config;
|
|
35
|
+
return {
|
|
36
|
+
name: 'vite-plugin-react-server-components',
|
|
37
|
+
enforce: 'pre',
|
|
38
|
+
configResolved: function (_config) {
|
|
39
|
+
config = _config;
|
|
40
|
+
},
|
|
41
|
+
resolveId: async function (source, importer) {
|
|
42
|
+
if (!importer) return null;
|
|
43
|
+
/**
|
|
44
|
+
* Throw errors when non-Server Components try to load Server Components.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
if (
|
|
48
|
+
/\.server(\.[jt]sx?)?$/.test(source) &&
|
|
49
|
+
!(
|
|
50
|
+
/(\.server\.[jt]sx?|entry-server\.[jt]sx?|index\.html)$/.test(
|
|
51
|
+
importer
|
|
52
|
+
) || isServerComponentImporterAllowed(importer, source)
|
|
53
|
+
)
|
|
54
|
+
) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'Cannot import ' +
|
|
57
|
+
source +
|
|
58
|
+
' from "' +
|
|
59
|
+
importer +
|
|
60
|
+
'". ' +
|
|
61
|
+
'By react-server convention, .server.js files can only be imported from other .server.js files. ' +
|
|
62
|
+
'That way nobody accidentally sends these to the client by indirectly importing it.'
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
load: async function (id) {
|
|
67
|
+
var options =
|
|
68
|
+
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
+
if (!options.ssr) return null; // Wrapped components won't match this becase they end in ?no-proxy
|
|
70
|
+
|
|
71
|
+
if (/\.client\.[jt]sx?$/.test(id)) {
|
|
72
|
+
return proxyClientComponent(id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
},
|
|
77
|
+
transform: function (code, id) {
|
|
78
|
+
/**
|
|
79
|
+
* In order to allow dynamic component imports from RSC, we use Vite's import.meta.glob.
|
|
80
|
+
* This hook replaces the glob placeholders with resolved paths to all client components.
|
|
81
|
+
*
|
|
82
|
+
* NOTE: Glob import paths MUST be relative to the importer file in
|
|
83
|
+
* order to get the `?v=xxx` querystring from Vite added to the import URL.
|
|
84
|
+
* If the paths are relative to the root instead, Vite won't add the querystring
|
|
85
|
+
* and we will have duplicated files in the browser (with duplicated contexts, etc).
|
|
86
|
+
*/
|
|
87
|
+
if (/\/react-server-dom-vite.js/.test(id)) {
|
|
88
|
+
var CLIENT_COMPONENT_GLOB = '**/*.client.[jt]s?(x)';
|
|
89
|
+
var importerPath = path.dirname(id);
|
|
90
|
+
var importerToRootPath = vite.normalizePath(
|
|
91
|
+
path.relative(importerPath, config.root)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
var _ref2 = importerToRootPath.match(/(\.\.\/)+(\.\.)?/) || [],
|
|
95
|
+
importerToRootNested = _ref2[0];
|
|
96
|
+
|
|
97
|
+
var userPrefix = path.normalize(
|
|
98
|
+
path.join(
|
|
99
|
+
importerPath,
|
|
100
|
+
importerToRootNested.replace(/\/?$/, path.sep)
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
var userGlob = path.join(
|
|
104
|
+
importerToRootPath,
|
|
105
|
+
'src',
|
|
106
|
+
CLIENT_COMPONENT_GLOB
|
|
107
|
+
);
|
|
108
|
+
// Fix for windows: avoid ending strings in backslash
|
|
109
|
+
var dummySuffix = '#';
|
|
110
|
+
var importers = [[userGlob, userPrefix + dummySuffix]];
|
|
111
|
+
clientComponentPaths.forEach(function (componentPath) {
|
|
112
|
+
var libPrefix = componentPath + path.sep + dummySuffix;
|
|
113
|
+
var libGlob = path.join(
|
|
114
|
+
path.relative(importerPath, componentPath),
|
|
115
|
+
CLIENT_COMPONENT_GLOB
|
|
116
|
+
);
|
|
117
|
+
importers.push([libGlob, libPrefix]);
|
|
118
|
+
});
|
|
119
|
+
var injectedGlobs =
|
|
120
|
+
'Object.assign(Object.create(null), ' +
|
|
121
|
+
importers
|
|
122
|
+
.map(function (_ref3) {
|
|
123
|
+
var glob = _ref3[0],
|
|
124
|
+
prefix = _ref3[1];
|
|
125
|
+
return (
|
|
126
|
+
"__vncp(import.meta.glob('" +
|
|
127
|
+
vite.normalizePath(glob) +
|
|
128
|
+
"'), '" +
|
|
129
|
+
vite.normalizePath(prefix) +
|
|
130
|
+
"')"
|
|
131
|
+
);
|
|
132
|
+
})
|
|
133
|
+
.join(', ') +
|
|
134
|
+
');';
|
|
135
|
+
return code.replace(
|
|
136
|
+
/\{\s*__INJECTED_CLIENT_IMPORTERS__[:\s]*null[,\s]*\}\s*;/,
|
|
137
|
+
injectedGlobs + serializedNormalizePaths()
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var serializedNormalizePaths = function () {
|
|
145
|
+
return "\nfunction __vncp(obj, prefix) {\n const nestedRE = /\\.\\.\\//gm;\n return Object.keys(obj).reduce(function (acc, key) {\n acc[prefix.slice(0, -1) + key.replace(nestedRE, '')] = obj[key];\n return acc;\n }, {});\n}\n";
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
async function proxyClientComponent(id, src) {
|
|
149
|
+
var DEFAULT_EXPORT = 'default'; // Modify the import ID to avoid infinite wraps
|
|
150
|
+
|
|
151
|
+
var importFrom = id + '?no-proxy';
|
|
152
|
+
await esModuleLexer.init;
|
|
153
|
+
|
|
154
|
+
if (!src) {
|
|
155
|
+
src = await fs.promises.readFile(id, 'utf-8');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
var _await$transformWithE = await vite.transformWithEsbuild(src, id),
|
|
159
|
+
code = _await$transformWithE.code;
|
|
160
|
+
|
|
161
|
+
var _parse = esModuleLexer.parse(code),
|
|
162
|
+
exportStatements = _parse[1];
|
|
163
|
+
|
|
164
|
+
var proxyCode =
|
|
165
|
+
"import {wrapInClientProxy} from 'react-server-dom-vite/client-proxy';\n" +
|
|
166
|
+
("import * as allImports from '" + importFrom + "';\n\n"); // Wrap components in Client Proxy
|
|
167
|
+
|
|
168
|
+
exportStatements.forEach(function (key) {
|
|
169
|
+
var isDefault = key === DEFAULT_EXPORT;
|
|
170
|
+
var componentName = isDefault
|
|
171
|
+
? id.split('/').pop().split('.').shift()
|
|
172
|
+
: key;
|
|
173
|
+
proxyCode +=
|
|
174
|
+
'export ' +
|
|
175
|
+
(isDefault ? DEFAULT_EXPORT : 'const ' + componentName + ' =') +
|
|
176
|
+
" wrapInClientProxy({ name: '" +
|
|
177
|
+
componentName +
|
|
178
|
+
"', id: '" +
|
|
179
|
+
id +
|
|
180
|
+
"', component: allImports['" +
|
|
181
|
+
key +
|
|
182
|
+
"'], named: " + // eslint-disable-next-line react-internal/safe-string-coercion
|
|
183
|
+
String(!isDefault) +
|
|
184
|
+
' });\n';
|
|
185
|
+
});
|
|
186
|
+
return proxyCode;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
module.exports = ReactFlightVitePlugin;
|