@atlaspack/resolver-tesseract 2.15.9-dev-yarn-8750a7d2e.0 → 2.15.9
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/CHANGELOG.md +11 -0
- package/dist/TesseractResolver.js +34 -17
- package/lib/TesseractResolver.js +34 -18
- package/package.json +5 -6
- package/src/TesseractResolver.ts +43 -20
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.15.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#848](https://github.com/atlassian-labs/atlaspack/pull/848) [`26fcd0c`](https://github.com/atlassian-labs/atlaspack/commit/26fcd0ca1ede7c9e178cda01aa68d10fbeb8b405) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - add react-dom/server handling
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @atlaspack/node-resolver-core@3.7.7
|
|
11
|
+
- @atlaspack/types-internal@2.20.6
|
|
12
|
+
- @atlaspack/plugin@2.14.36
|
|
13
|
+
|
|
3
14
|
## 2.15.8
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -63,6 +63,7 @@ exports.default = new plugin_1.Resolver({
|
|
|
63
63
|
const serverSuffixes = userConfig.serverSuffixes || [];
|
|
64
64
|
const ignoreModules = userConfig.ignoreModules || [];
|
|
65
65
|
const browserResolvedNodeBuiltins = userConfig.browserResolvedNodeBuiltins || [];
|
|
66
|
+
const handleReactDomServer = userConfig.handleReactDomServer || false;
|
|
66
67
|
const nodeResolver = new node_resolver_core_1.default({
|
|
67
68
|
fs: options.inputFS,
|
|
68
69
|
projectRoot: options.projectRoot,
|
|
@@ -89,10 +90,11 @@ exports.default = new plugin_1.Resolver({
|
|
|
89
90
|
builtinAliases,
|
|
90
91
|
ignoreModules,
|
|
91
92
|
browserResolvedNodeBuiltins,
|
|
93
|
+
handleReactDomServer,
|
|
92
94
|
};
|
|
93
95
|
},
|
|
94
96
|
resolve({ dependency, specifier, config, options }) {
|
|
95
|
-
const { nodeResolver, browserResolver, ignoreModules, browserResolvedNodeBuiltins, preResolved, builtinAliases, serverSuffixes, } = config;
|
|
97
|
+
const { nodeResolver, browserResolver, ignoreModules, browserResolvedNodeBuiltins, preResolved, builtinAliases, serverSuffixes, handleReactDomServer, } = config;
|
|
96
98
|
if ((0, path_1.isAbsolute)(specifier)) {
|
|
97
99
|
return {
|
|
98
100
|
filePath: specifier,
|
|
@@ -132,34 +134,49 @@ exports.default = new plugin_1.Resolver({
|
|
|
132
134
|
const useBrowser = browserResolvedNodeBuiltins.includes(specifier) ||
|
|
133
135
|
(options.env.STATIC_FALLBACK === 'true' &&
|
|
134
136
|
STATIC_FALLBACK_MODULES.includes(specifier));
|
|
137
|
+
const snapvmEnv = new Proxy(dependency.env, {
|
|
138
|
+
get(target, property) {
|
|
139
|
+
if (handleReactDomServer && specifier.includes('react-dom/server')) {
|
|
140
|
+
if (property === 'isNode') {
|
|
141
|
+
return () => true;
|
|
142
|
+
}
|
|
143
|
+
if (property === 'isBrowser') {
|
|
144
|
+
return () => false;
|
|
145
|
+
}
|
|
146
|
+
if (property === 'isWorker') {
|
|
147
|
+
return () => false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (property === 'isLibrary') {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (typeof property === 'string') {
|
|
154
|
+
const value = target[property];
|
|
155
|
+
const ret = typeof value === 'function' ? value.bind(target) : value;
|
|
156
|
+
return ret;
|
|
157
|
+
}
|
|
158
|
+
return Reflect.get(target, property);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
const packageConditions = handleReactDomServer && specifier.includes('react-dom/server')
|
|
162
|
+
? ['default']
|
|
163
|
+
: ['ssr', 'require'];
|
|
135
164
|
const promise = useBrowser
|
|
136
165
|
? browserResolver.resolve({
|
|
137
166
|
sourcePath: dependency.sourcePath,
|
|
138
167
|
parent: dependency.resolveFrom,
|
|
139
168
|
filename: aliasSpecifier || specifier,
|
|
140
169
|
specifierType: dependency.specifierType,
|
|
141
|
-
env:
|
|
142
|
-
|
|
143
|
-
if (property === 'isLibrary') {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
if (typeof property === 'string') {
|
|
147
|
-
const value = target[property];
|
|
148
|
-
const ret = typeof value === 'function' ? value.bind(target) : value;
|
|
149
|
-
return ret;
|
|
150
|
-
}
|
|
151
|
-
return Reflect.get(target, property);
|
|
152
|
-
},
|
|
153
|
-
}),
|
|
154
|
-
packageConditions: ['ssr', 'require'],
|
|
170
|
+
env: snapvmEnv,
|
|
171
|
+
packageConditions,
|
|
155
172
|
})
|
|
156
173
|
: nodeResolver.resolve({
|
|
157
174
|
sourcePath: dependency.sourcePath,
|
|
158
175
|
parent: dependency.resolveFrom,
|
|
159
176
|
filename: aliasSpecifier || specifier,
|
|
160
177
|
specifierType: dependency.specifierType,
|
|
161
|
-
env: dependency.env,
|
|
162
|
-
packageConditions
|
|
178
|
+
env: handleReactDomServer ? snapvmEnv : dependency.env,
|
|
179
|
+
packageConditions,
|
|
163
180
|
});
|
|
164
181
|
return promise
|
|
165
182
|
.then(async (result) => {
|
package/lib/TesseractResolver.js
CHANGED
|
@@ -82,6 +82,7 @@ var _default = exports.default = new (_plugin().Resolver)({
|
|
|
82
82
|
const serverSuffixes = userConfig.serverSuffixes || [];
|
|
83
83
|
const ignoreModules = userConfig.ignoreModules || [];
|
|
84
84
|
const browserResolvedNodeBuiltins = userConfig.browserResolvedNodeBuiltins || [];
|
|
85
|
+
const handleReactDomServer = userConfig.handleReactDomServer || false;
|
|
85
86
|
const nodeResolver = new (_nodeResolverCore().default)({
|
|
86
87
|
fs: options.inputFS,
|
|
87
88
|
projectRoot: options.projectRoot,
|
|
@@ -107,7 +108,8 @@ var _default = exports.default = new (_plugin().Resolver)({
|
|
|
107
108
|
preResolved,
|
|
108
109
|
builtinAliases,
|
|
109
110
|
ignoreModules,
|
|
110
|
-
browserResolvedNodeBuiltins
|
|
111
|
+
browserResolvedNodeBuiltins,
|
|
112
|
+
handleReactDomServer
|
|
111
113
|
};
|
|
112
114
|
},
|
|
113
115
|
resolve({
|
|
@@ -123,7 +125,8 @@ var _default = exports.default = new (_plugin().Resolver)({
|
|
|
123
125
|
browserResolvedNodeBuiltins,
|
|
124
126
|
preResolved,
|
|
125
127
|
builtinAliases,
|
|
126
|
-
serverSuffixes
|
|
128
|
+
serverSuffixes,
|
|
129
|
+
handleReactDomServer
|
|
127
130
|
} = config;
|
|
128
131
|
if ((0, _path().isAbsolute)(specifier)) {
|
|
129
132
|
return {
|
|
@@ -161,32 +164,45 @@ var _default = exports.default = new (_plugin().Resolver)({
|
|
|
161
164
|
}
|
|
162
165
|
const aliasSpecifier = options.env.STATIC_FALLBACK === 'true' ? STATIC_FALLBACK_ALIAS[specifier] : builtinAliases[specifier];
|
|
163
166
|
const useBrowser = browserResolvedNodeBuiltins.includes(specifier) || options.env.STATIC_FALLBACK === 'true' && STATIC_FALLBACK_MODULES.includes(specifier);
|
|
167
|
+
const snapvmEnv = new Proxy(dependency.env, {
|
|
168
|
+
get(target, property) {
|
|
169
|
+
if (handleReactDomServer && specifier.includes('react-dom/server')) {
|
|
170
|
+
if (property === 'isNode') {
|
|
171
|
+
return () => true;
|
|
172
|
+
}
|
|
173
|
+
if (property === 'isBrowser') {
|
|
174
|
+
return () => false;
|
|
175
|
+
}
|
|
176
|
+
if (property === 'isWorker') {
|
|
177
|
+
return () => false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (property === 'isLibrary') {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
if (typeof property === 'string') {
|
|
184
|
+
const value = target[property];
|
|
185
|
+
const ret = typeof value === 'function' ? value.bind(target) : value;
|
|
186
|
+
return ret;
|
|
187
|
+
}
|
|
188
|
+
return Reflect.get(target, property);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const packageConditions = handleReactDomServer && specifier.includes('react-dom/server') ? ['default'] : ['ssr', 'require'];
|
|
164
192
|
const promise = useBrowser ? browserResolver.resolve({
|
|
165
193
|
sourcePath: dependency.sourcePath,
|
|
166
194
|
parent: dependency.resolveFrom,
|
|
167
195
|
filename: aliasSpecifier || specifier,
|
|
168
196
|
specifierType: dependency.specifierType,
|
|
169
|
-
env:
|
|
170
|
-
|
|
171
|
-
if (property === 'isLibrary') {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
if (typeof property === 'string') {
|
|
175
|
-
const value = target[property];
|
|
176
|
-
const ret = typeof value === 'function' ? value.bind(target) : value;
|
|
177
|
-
return ret;
|
|
178
|
-
}
|
|
179
|
-
return Reflect.get(target, property);
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
packageConditions: ['ssr', 'require']
|
|
197
|
+
env: snapvmEnv,
|
|
198
|
+
packageConditions
|
|
183
199
|
}) : nodeResolver.resolve({
|
|
184
200
|
sourcePath: dependency.sourcePath,
|
|
185
201
|
parent: dependency.resolveFrom,
|
|
186
202
|
filename: aliasSpecifier || specifier,
|
|
187
203
|
specifierType: dependency.specifierType,
|
|
188
|
-
env: dependency.env,
|
|
189
|
-
packageConditions
|
|
204
|
+
env: handleReactDomServer ? snapvmEnv : dependency.env,
|
|
205
|
+
packageConditions
|
|
190
206
|
});
|
|
191
207
|
return promise.then(async result => {
|
|
192
208
|
const resolvedPath = result === null || result === void 0 ? void 0 : result.filePath;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/resolver-tesseract",
|
|
3
|
-
"version": "2.15.9
|
|
3
|
+
"version": "2.15.9",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/node-resolver-core": "3.7.7
|
|
20
|
-
"@atlaspack/plugin": "2.14.36
|
|
21
|
-
"@atlaspack/types-internal": "2.20.6
|
|
19
|
+
"@atlaspack/node-resolver-core": "3.7.7",
|
|
20
|
+
"@atlaspack/plugin": "2.14.36",
|
|
21
|
+
"@atlaspack/types-internal": "2.20.6"
|
|
22
22
|
},
|
|
23
23
|
"type": "commonjs",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
26
|
-
}
|
|
27
|
-
"gitHead": "8750a7d2e6330244dd618c28a20d5a391080e4a3"
|
|
26
|
+
}
|
|
28
27
|
}
|
package/src/TesseractResolver.ts
CHANGED
|
@@ -18,6 +18,9 @@ interface TesseractResolverConfig {
|
|
|
18
18
|
|
|
19
19
|
/** Server file suffixes checked in priority order. */
|
|
20
20
|
serverSuffixes?: Array<string>;
|
|
21
|
+
|
|
22
|
+
/** Enable React DOM Server specific behavior. */
|
|
23
|
+
handleReactDomServer?: boolean;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
const IGNORE_MODULES_REGEX = /(mock|mocks|\.woff|\.woff2|\.mp3|\.ogg)$/;
|
|
@@ -101,7 +104,7 @@ export default new Resolver({
|
|
|
101
104
|
const ignoreModules = userConfig.ignoreModules || [];
|
|
102
105
|
const browserResolvedNodeBuiltins =
|
|
103
106
|
userConfig.browserResolvedNodeBuiltins || [];
|
|
104
|
-
|
|
107
|
+
const handleReactDomServer = userConfig.handleReactDomServer || false;
|
|
105
108
|
const nodeResolver = new NodeResolver({
|
|
106
109
|
fs: options.inputFS,
|
|
107
110
|
projectRoot: options.projectRoot,
|
|
@@ -130,6 +133,7 @@ export default new Resolver({
|
|
|
130
133
|
builtinAliases,
|
|
131
134
|
ignoreModules,
|
|
132
135
|
browserResolvedNodeBuiltins,
|
|
136
|
+
handleReactDomServer,
|
|
133
137
|
};
|
|
134
138
|
},
|
|
135
139
|
resolve({dependency, specifier, config, options}) {
|
|
@@ -141,6 +145,7 @@ export default new Resolver({
|
|
|
141
145
|
preResolved,
|
|
142
146
|
builtinAliases,
|
|
143
147
|
serverSuffixes,
|
|
148
|
+
handleReactDomServer,
|
|
144
149
|
} = config;
|
|
145
150
|
|
|
146
151
|
if (isAbsolute(specifier)) {
|
|
@@ -194,37 +199,55 @@ export default new Resolver({
|
|
|
194
199
|
(options.env.STATIC_FALLBACK === 'true' &&
|
|
195
200
|
STATIC_FALLBACK_MODULES.includes(specifier));
|
|
196
201
|
|
|
202
|
+
const snapvmEnv = new Proxy(dependency.env, {
|
|
203
|
+
get(target, property) {
|
|
204
|
+
if (handleReactDomServer && specifier.includes('react-dom/server')) {
|
|
205
|
+
if (property === 'isNode') {
|
|
206
|
+
return () => true;
|
|
207
|
+
}
|
|
208
|
+
if (property === 'isBrowser') {
|
|
209
|
+
return () => false;
|
|
210
|
+
}
|
|
211
|
+
if (property === 'isWorker') {
|
|
212
|
+
return () => false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (property === 'isLibrary') {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (typeof property === 'string') {
|
|
221
|
+
const value = target[property as keyof typeof target];
|
|
222
|
+
const ret = typeof value === 'function' ? value.bind(target) : value;
|
|
223
|
+
return ret;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return Reflect.get(target, property);
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const packageConditions =
|
|
231
|
+
handleReactDomServer && specifier.includes('react-dom/server')
|
|
232
|
+
? ['default']
|
|
233
|
+
: ['ssr', 'require'];
|
|
234
|
+
|
|
197
235
|
const promise = useBrowser
|
|
198
236
|
? browserResolver.resolve({
|
|
199
237
|
sourcePath: dependency.sourcePath,
|
|
200
238
|
parent: dependency.resolveFrom,
|
|
201
239
|
filename: aliasSpecifier || specifier,
|
|
202
240
|
specifierType: dependency.specifierType,
|
|
203
|
-
env:
|
|
204
|
-
|
|
205
|
-
if (property === 'isLibrary') {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (typeof property === 'string') {
|
|
210
|
-
const value = target[property as keyof typeof target];
|
|
211
|
-
const ret =
|
|
212
|
-
typeof value === 'function' ? value.bind(target) : value;
|
|
213
|
-
return ret;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return Reflect.get(target, property);
|
|
217
|
-
},
|
|
218
|
-
}),
|
|
219
|
-
packageConditions: ['ssr', 'require'],
|
|
241
|
+
env: snapvmEnv,
|
|
242
|
+
packageConditions,
|
|
220
243
|
})
|
|
221
244
|
: nodeResolver.resolve({
|
|
222
245
|
sourcePath: dependency.sourcePath,
|
|
223
246
|
parent: dependency.resolveFrom,
|
|
224
247
|
filename: aliasSpecifier || specifier,
|
|
225
248
|
specifierType: dependency.specifierType,
|
|
226
|
-
env: dependency.env,
|
|
227
|
-
packageConditions
|
|
249
|
+
env: handleReactDomServer ? snapvmEnv : dependency.env,
|
|
250
|
+
packageConditions,
|
|
228
251
|
});
|
|
229
252
|
|
|
230
253
|
return promise
|