@atlaspack/transformer-js 3.3.10 → 3.3.11-typescript-08dcc1c9b.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/LICENSE +201 -0
- package/lib/JSTransformer.js +80 -33
- package/package.json +13 -10
- package/src/{JSTransformer.js → JSTransformer.ts} +112 -69
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2024 Atlassian US., Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/lib/JSTransformer.js
CHANGED
|
@@ -188,18 +188,25 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
188
188
|
})) === null || _await$config$getConf === void 0 || (_await$config$getConf = _await$config$getConf.contents) === null || _await$config$getConf === void 0 ? void 0 : _await$config$getConf.compilerOptions;
|
|
189
189
|
|
|
190
190
|
// Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
|
|
191
|
-
pragma = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFactory) || (
|
|
192
|
-
|
|
191
|
+
pragma = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFactory) || (
|
|
192
|
+
// @ts-expect-error TS7053
|
|
193
|
+
reactLib ? JSX_PRAGMA[reactLib].pragma : undefined);
|
|
194
|
+
pragmaFrag = (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxFragmentFactory) || (
|
|
195
|
+
// @ts-expect-error TS7053
|
|
196
|
+
reactLib ? JSX_PRAGMA[reactLib].pragmaFrag : undefined);
|
|
193
197
|
if ((compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsx) === 'react-jsx' || (compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsx) === 'react-jsxdev' || compilerOptions !== null && compilerOptions !== void 0 && compilerOptions.jsxImportSource) {
|
|
194
198
|
jsxImportSource = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.jsxImportSource;
|
|
195
199
|
automaticJSXRuntime = true;
|
|
196
200
|
} else if (reactLib) {
|
|
197
201
|
var _JSX_PRAGMA$effective, _packageJson$dependen3, _packageJson$devDepen3, _packageJson$peerDepe3, _semver$minVersion;
|
|
198
202
|
let effectiveReactLib = packageJson !== null && packageJson !== void 0 && packageJson.alias && packageJson.alias['react'] === 'preact/compat' ? 'preact' : reactLib;
|
|
203
|
+
// @ts-expect-error TS7053
|
|
199
204
|
let automaticVersion = (_JSX_PRAGMA$effective = JSX_PRAGMA[effectiveReactLib]) === null || _JSX_PRAGMA$effective === void 0 ? void 0 : _JSX_PRAGMA$effective.automatic;
|
|
200
205
|
let reactLibVersion = (packageJson === null || packageJson === void 0 || (_packageJson$dependen3 = packageJson.dependencies) === null || _packageJson$dependen3 === void 0 ? void 0 : _packageJson$dependen3[effectiveReactLib]) || (packageJson === null || packageJson === void 0 || (_packageJson$devDepen3 = packageJson.devDependencies) === null || _packageJson$devDepen3 === void 0 ? void 0 : _packageJson$devDepen3[effectiveReactLib]) || (packageJson === null || packageJson === void 0 || (_packageJson$peerDepe3 = packageJson.peerDependencies) === null || _packageJson$peerDepe3 === void 0 ? void 0 : _packageJson$peerDepe3[effectiveReactLib]);
|
|
206
|
+
// @ts-expect-error TS2322
|
|
201
207
|
reactLibVersion = reactLibVersion ? _semver().default.validRange(reactLibVersion) : null;
|
|
202
|
-
let minReactLibVersion = reactLibVersion !== null && reactLibVersion !== '*' ?
|
|
208
|
+
let minReactLibVersion = reactLibVersion !== null && reactLibVersion !== '*' ? // @ts-expect-error TS2345
|
|
209
|
+
(_semver$minVersion = _semver().default.minVersion(reactLibVersion)) === null || _semver$minVersion === void 0 ? void 0 : _semver$minVersion.toString() : null;
|
|
203
210
|
automaticJSXRuntime = automaticVersion && !(compilerOptions !== null && compilerOptions !== void 0 && compilerOptions.jsxFactory) && minReactLibVersion != null && _semver().default.satisfies(minReactLibVersion, automaticVersion, {
|
|
204
211
|
includePrerelease: true
|
|
205
212
|
});
|
|
@@ -242,10 +249,16 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
242
249
|
},
|
|
243
250
|
// FIXME
|
|
244
251
|
'@atlaspack/transformer-js', 'Invalid config for @atlaspack/transformer-js');
|
|
252
|
+
|
|
253
|
+
// @ts-expect-error TS2339
|
|
245
254
|
magicComments = ((_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.magicComments) ?? magicComments;
|
|
255
|
+
// @ts-expect-error TS2339
|
|
246
256
|
inlineEnvironment = ((_conf$contents2 = conf.contents) === null || _conf$contents2 === void 0 ? void 0 : _conf$contents2.inlineEnvironment) ?? inlineEnvironment;
|
|
257
|
+
// @ts-expect-error TS2339
|
|
247
258
|
inlineFS = ((_conf$contents3 = conf.contents) === null || _conf$contents3 === void 0 ? void 0 : _conf$contents3.inlineFS) ?? inlineFS;
|
|
248
|
-
inlineConstants =
|
|
259
|
+
inlineConstants =
|
|
260
|
+
// @ts-expect-error TS2339
|
|
261
|
+
((_conf$contents4 = conf.contents) === null || _conf$contents4 === void 0 ? void 0 : _conf$contents4.unstable_inlineConstants) ?? inlineConstants;
|
|
249
262
|
}
|
|
250
263
|
return {
|
|
251
264
|
isJSX,
|
|
@@ -288,17 +301,22 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
288
301
|
for (let browser of browsers) {
|
|
289
302
|
let [name, version] = browser.split(' ');
|
|
290
303
|
if (BROWSER_MAPPING.hasOwnProperty(name)) {
|
|
304
|
+
// @ts-expect-error TS7053
|
|
291
305
|
name = BROWSER_MAPPING[name];
|
|
292
306
|
if (!name) {
|
|
293
307
|
continue;
|
|
294
308
|
}
|
|
295
309
|
}
|
|
296
310
|
let [major, minor = '0', patch = '0'] = version.split('-')[0].split('.');
|
|
311
|
+
// @ts-expect-error TS2345
|
|
297
312
|
if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
|
|
298
313
|
continue;
|
|
299
314
|
}
|
|
300
315
|
let semverVersion = `${major}.${minor}.${patch}`;
|
|
316
|
+
|
|
317
|
+
// @ts-expect-error TS2345
|
|
301
318
|
if (targets[name] == null || _semver().default.gt(targets[name], semverVersion)) {
|
|
319
|
+
// @ts-expect-error TS7053
|
|
302
320
|
targets[name] = semverVersion;
|
|
303
321
|
}
|
|
304
322
|
}
|
|
@@ -309,8 +327,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
309
327
|
};
|
|
310
328
|
}
|
|
311
329
|
let env = {};
|
|
312
|
-
|
|
313
|
-
// $FlowFixMe
|
|
314
330
|
if (!(config !== null && config !== void 0 && config.inlineEnvironment)) {
|
|
315
331
|
if (options.env.NODE_ENV != null) {
|
|
316
332
|
env.NODE_ENV = options.env.NODE_ENV;
|
|
@@ -319,9 +335,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
319
335
|
env.ATLASPACK_BUILD_ENV = 'test';
|
|
320
336
|
}
|
|
321
337
|
} else if (Array.isArray(config === null || config === void 0 ? void 0 : config.inlineEnvironment)) {
|
|
322
|
-
for (let match of (0, _utils().globMatch)(Object.keys(options.env),
|
|
323
|
-
// $FlowFixMe
|
|
324
|
-
config.inlineEnvironment)) {
|
|
338
|
+
for (let match of (0, _utils().globMatch)(Object.keys(options.env), config.inlineEnvironment)) {
|
|
325
339
|
env[match] = String(options.env[match]);
|
|
326
340
|
}
|
|
327
341
|
} else {
|
|
@@ -332,29 +346,42 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
332
346
|
}
|
|
333
347
|
}
|
|
334
348
|
let supportsModuleWorkers = asset.env.shouldScopeHoist && asset.env.supports('worker-module', true);
|
|
335
|
-
// $FlowFixMe
|
|
336
349
|
let isJSX = Boolean(config === null || config === void 0 ? void 0 : config.isJSX);
|
|
337
350
|
if (asset.isSource) {
|
|
338
351
|
if (asset.type === 'ts') {
|
|
339
352
|
isJSX = false;
|
|
340
353
|
} else if (!isJSX) {
|
|
354
|
+
// @ts-expect-error TS7053
|
|
341
355
|
isJSX = Boolean(JSX_EXTENSIONS[asset.type]);
|
|
342
356
|
}
|
|
343
357
|
}
|
|
344
358
|
let macroAssets = [];
|
|
345
359
|
let {
|
|
360
|
+
// @ts-expect-error TS2339
|
|
346
361
|
dependencies,
|
|
362
|
+
// @ts-expect-error TS2339
|
|
347
363
|
code: compiledCode,
|
|
364
|
+
// @ts-expect-error TS2339
|
|
348
365
|
map,
|
|
366
|
+
// @ts-expect-error TS2339
|
|
349
367
|
shebang,
|
|
368
|
+
// @ts-expect-error TS2339
|
|
350
369
|
hoist_result,
|
|
370
|
+
// @ts-expect-error TS2339
|
|
351
371
|
symbol_result,
|
|
372
|
+
// @ts-expect-error TS2339
|
|
352
373
|
is_empty_or_empty_export,
|
|
374
|
+
// @ts-expect-error TS2339
|
|
353
375
|
needs_esm_helpers,
|
|
376
|
+
// @ts-expect-error TS2339
|
|
354
377
|
diagnostics,
|
|
378
|
+
// @ts-expect-error TS2339
|
|
355
379
|
used_env,
|
|
380
|
+
// @ts-expect-error TS2339
|
|
356
381
|
has_node_replacements,
|
|
382
|
+
// @ts-expect-error TS2339
|
|
357
383
|
is_constant_module,
|
|
384
|
+
// @ts-expect-error TS2339
|
|
358
385
|
conditions
|
|
359
386
|
} = await (_rust().transformAsync || _rust().transform)({
|
|
360
387
|
filename: asset.filePath,
|
|
@@ -362,7 +389,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
362
389
|
module_id: asset.id,
|
|
363
390
|
project_root: options.projectRoot,
|
|
364
391
|
replace_env: !asset.env.isNode(),
|
|
365
|
-
// $FlowFixMe
|
|
366
392
|
inline_fs: Boolean(config === null || config === void 0 ? void 0 : config.inlineFS) && !asset.env.isNode(),
|
|
367
393
|
insert_node_globals: !asset.env.isNode() && asset.env.sourceType !== 'script',
|
|
368
394
|
node_replacer: asset.env.isNode(),
|
|
@@ -371,21 +397,13 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
371
397
|
env,
|
|
372
398
|
is_type_script: asset.type === 'ts' || asset.type === 'tsx',
|
|
373
399
|
is_jsx: isJSX,
|
|
374
|
-
// $FlowFixMe
|
|
375
400
|
jsx_pragma: config === null || config === void 0 ? void 0 : config.pragma,
|
|
376
|
-
// $FlowFixMe
|
|
377
401
|
jsx_pragma_frag: config === null || config === void 0 ? void 0 : config.pragmaFrag,
|
|
378
|
-
// $FlowFixMe
|
|
379
402
|
automatic_jsx_runtime: Boolean(config === null || config === void 0 ? void 0 : config.automaticJSXRuntime),
|
|
380
|
-
// $FlowFixMe
|
|
381
403
|
jsx_import_source: config === null || config === void 0 ? void 0 : config.jsxImportSource,
|
|
382
404
|
is_development: options.mode === 'development',
|
|
383
|
-
react_refresh: asset.env.isBrowser() && !asset.env.isLibrary && !asset.env.isWorker() && !asset.env.isWorklet() &&
|
|
384
|
-
// $FlowFixMe
|
|
385
|
-
Boolean(config === null || config === void 0 ? void 0 : config.reactRefresh),
|
|
386
|
-
// $FlowFixMe
|
|
405
|
+
react_refresh: asset.env.isBrowser() && !asset.env.isLibrary && !asset.env.isWorker() && !asset.env.isWorklet() && Boolean(config === null || config === void 0 ? void 0 : config.reactRefresh),
|
|
387
406
|
decorators: Boolean(config === null || config === void 0 ? void 0 : config.decorators),
|
|
388
|
-
// $FlowFixMe
|
|
389
407
|
use_define_for_class_fields: Boolean(config === null || config === void 0 ? void 0 : config.useDefineForClassFields),
|
|
390
408
|
targets,
|
|
391
409
|
source_maps: !!asset.env.sourceMap,
|
|
@@ -397,12 +415,10 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
397
415
|
trace_bailouts: options.logLevel === 'verbose',
|
|
398
416
|
is_swc_helpers: /@swc[/\\]helpers/.test(asset.filePath),
|
|
399
417
|
standalone: asset.query.has('standalone'),
|
|
400
|
-
// $FlowFixMe
|
|
401
418
|
inline_constants: config.inlineConstants,
|
|
402
419
|
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
403
420
|
hmr_improvements: options.featureFlags.hmrImprovements,
|
|
404
421
|
computed_properties_fix: options.featureFlags.unusedComputedPropertyFix,
|
|
405
|
-
// $FlowFixMe
|
|
406
422
|
magic_comments: Boolean(config === null || config === void 0 ? void 0 : config.magicComments),
|
|
407
423
|
callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
|
|
408
424
|
let mod;
|
|
@@ -410,9 +426,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
410
426
|
mod = await options.packageManager.require(src, asset.filePath);
|
|
411
427
|
|
|
412
428
|
// Default interop for CommonJS modules.
|
|
413
|
-
if (exportName === 'default' && !mod.__esModule &&
|
|
414
|
-
// $FlowFixMe
|
|
415
|
-
Object.prototype.toString.call(config) !== '[object Module]') {
|
|
429
|
+
if (exportName === 'default' && !mod.__esModule && Object.prototype.toString.call(config) !== '[object Module]') {
|
|
416
430
|
mod = {
|
|
417
431
|
default: mod
|
|
418
432
|
};
|
|
@@ -436,6 +450,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
436
450
|
if (asset.env.sourceMap) {
|
|
437
451
|
// Generate a source map that maps each line of the asset to the original macro call.
|
|
438
452
|
map = new (_sourceMap().default)(options.projectRoot);
|
|
453
|
+
// @ts-expect-error TS2304
|
|
439
454
|
let mappings = [];
|
|
440
455
|
let line = 1;
|
|
441
456
|
for (let i = 0; i <= a.content.length; i++) {
|
|
@@ -456,6 +471,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
456
471
|
}
|
|
457
472
|
map.addIndexedMappings(mappings);
|
|
458
473
|
if (originalMap) {
|
|
474
|
+
// @ts-expect-error TS2345
|
|
459
475
|
map.extends(originalMap);
|
|
460
476
|
} else {
|
|
461
477
|
map.setSourceContent(asset.filePath, code.toString());
|
|
@@ -510,7 +526,9 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
510
526
|
} : null
|
|
511
527
|
});
|
|
512
528
|
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi')) {
|
|
513
|
-
asset.meta.conditions = conditions.map(
|
|
529
|
+
asset.meta.conditions = conditions.map(
|
|
530
|
+
// @ts-expect-error TS7006
|
|
531
|
+
c => ({
|
|
514
532
|
key: c.key,
|
|
515
533
|
ifTruePlaceholder: c.if_true_placeholder,
|
|
516
534
|
ifFalsePlaceholder: c.if_false_placeholder
|
|
@@ -539,12 +557,17 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
539
557
|
return location;
|
|
540
558
|
};
|
|
541
559
|
if (diagnostics) {
|
|
542
|
-
let errors = diagnostics.filter(
|
|
543
|
-
|
|
560
|
+
let errors = diagnostics.filter(
|
|
561
|
+
// @ts-expect-error TS7006
|
|
562
|
+
d => d.severity === 'Error' || d.severity === 'SourceError' && asset.isSource);
|
|
563
|
+
let warnings = diagnostics.filter(
|
|
564
|
+
// @ts-expect-error TS7006
|
|
565
|
+
d => d.severity === 'Warning' || d.severity === 'SourceError' && !asset.isSource);
|
|
544
566
|
let convertDiagnostic = diagnostic => {
|
|
545
567
|
var _diagnostic$code_high;
|
|
546
568
|
let message = diagnostic.message;
|
|
547
569
|
if (message === 'SCRIPT_ERROR') {
|
|
570
|
+
// @ts-expect-error TS7053
|
|
548
571
|
let err = SCRIPT_ERRORS[asset.env.context];
|
|
549
572
|
message = (err === null || err === void 0 ? void 0 : err.message) || SCRIPT_ERRORS.browser.message;
|
|
550
573
|
}
|
|
@@ -567,6 +590,8 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
567
590
|
codeHighlights: [(0, _diagnostic().convertSourceLocationToHighlight)(asset.env.loc, 'The environment was originally created here')]
|
|
568
591
|
});
|
|
569
592
|
}
|
|
593
|
+
|
|
594
|
+
// @ts-expect-error TS7053
|
|
570
595
|
let err = SCRIPT_ERRORS[asset.env.context];
|
|
571
596
|
if (err) {
|
|
572
597
|
if (!res.hints) {
|
|
@@ -611,6 +636,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
611
636
|
env: {
|
|
612
637
|
context: 'web-worker',
|
|
613
638
|
sourceType: dep.source_type === 'Module' ? 'module' : 'script',
|
|
639
|
+
// @ts-expect-error TS2322
|
|
614
640
|
outputFormat,
|
|
615
641
|
loc
|
|
616
642
|
},
|
|
@@ -733,6 +759,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
733
759
|
idx = dep.specifier.indexOf('/', idx + 1);
|
|
734
760
|
}
|
|
735
761
|
let module = idx >= 0 ? dep.specifier.slice(0, idx) : dep.specifier;
|
|
762
|
+
// @ts-expect-error TS7053
|
|
736
763
|
range = _package.default.dependencies[module];
|
|
737
764
|
}
|
|
738
765
|
asset.addDependency({
|
|
@@ -744,6 +771,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
744
771
|
meta,
|
|
745
772
|
resolveFrom: isHelper ? __filename : undefined,
|
|
746
773
|
range,
|
|
774
|
+
// @ts-expect-error TS2322
|
|
747
775
|
env
|
|
748
776
|
});
|
|
749
777
|
}
|
|
@@ -790,11 +818,14 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
790
818
|
let dep = deps.get(source);
|
|
791
819
|
if (!dep) continue;
|
|
792
820
|
if (local === '*' && imported === '*') {
|
|
821
|
+
// @ts-expect-error TS2345
|
|
793
822
|
dep.symbols.set('*', '*', convertLoc(loc), true);
|
|
794
823
|
} else {
|
|
795
824
|
var _dep$symbols$get;
|
|
796
825
|
let reExportName = ((_dep$symbols$get = dep.symbols.get(imported)) === null || _dep$symbols$get === void 0 ? void 0 : _dep$symbols$get.local) ?? `$${asset.id}$re_export$${local}`;
|
|
826
|
+
// @ts-expect-error TS2345
|
|
797
827
|
asset.symbols.set(local, reExportName);
|
|
828
|
+
// @ts-expect-error TS2345
|
|
798
829
|
dep.symbols.set(imported, reExportName, convertLoc(loc), true);
|
|
799
830
|
}
|
|
800
831
|
}
|
|
@@ -812,7 +843,9 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
812
843
|
let symbols = new Map();
|
|
813
844
|
for (let name of hoist_result.self_references) {
|
|
814
845
|
// Do not create a self-reference for the `default` symbol unless we have seen an __esModule flag.
|
|
815
|
-
if (name === 'default' &&
|
|
846
|
+
if (name === 'default' &&
|
|
847
|
+
// @ts-expect-error TS2345
|
|
848
|
+
!asset.symbols.hasExportSymbol('__esModule')) {
|
|
816
849
|
continue;
|
|
817
850
|
}
|
|
818
851
|
let local = (0, _nullthrows().default)(asset.symbols.get(name)).local;
|
|
@@ -839,10 +872,13 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
839
872
|
// Add * symbol if there are CJS exports, no imports/exports at all
|
|
840
873
|
// (and the asset has side effects), or the asset is wrapped.
|
|
841
874
|
// This allows accessing symbols that don't exist without errors in symbol propagation.
|
|
842
|
-
if (hoist_result.has_cjs_exports || !hoist_result.is_esm && asset.sideEffects && deps.size === 0 && Object.keys(hoist_result.exported_symbols).length === 0 ||
|
|
875
|
+
if (hoist_result.has_cjs_exports || !hoist_result.is_esm && asset.sideEffects && deps.size === 0 && Object.keys(hoist_result.exported_symbols).length === 0 ||
|
|
876
|
+
// @ts-expect-error TS2345
|
|
877
|
+
hoist_result.should_wrap && !asset.symbols.hasExportSymbol('*')) {
|
|
843
878
|
if (is_empty_or_empty_export) {
|
|
844
879
|
asset.meta.emptyFileStarReexport = true;
|
|
845
880
|
}
|
|
881
|
+
// @ts-expect-error TS2345
|
|
846
882
|
asset.symbols.set('*', `$${asset.id}$exports`);
|
|
847
883
|
}
|
|
848
884
|
asset.meta.hasCJSExports = hoist_result.has_cjs_exports;
|
|
@@ -859,10 +895,14 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
859
895
|
source
|
|
860
896
|
} of symbol_result.exports) {
|
|
861
897
|
let dep = source ? deps.get(source) : undefined;
|
|
862
|
-
asset.symbols.set(exported,
|
|
898
|
+
asset.symbols.set(exported,
|
|
899
|
+
// @ts-expect-error TS2345
|
|
900
|
+
`${(dep === null || dep === void 0 ? void 0 : dep.id) ?? ''}$${local}`, convertLoc(loc));
|
|
863
901
|
if (dep != null) {
|
|
864
902
|
dep.symbols.ensure();
|
|
865
|
-
dep.symbols.set(local,
|
|
903
|
+
dep.symbols.set(local,
|
|
904
|
+
// @ts-expect-error TS2345
|
|
905
|
+
`${(dep === null || dep === void 0 ? void 0 : dep.id) ?? ''}$${local}`, convertLoc(loc), true);
|
|
866
906
|
}
|
|
867
907
|
}
|
|
868
908
|
for (let {
|
|
@@ -883,18 +923,23 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
883
923
|
let dep = deps.get(source);
|
|
884
924
|
if (!dep) continue;
|
|
885
925
|
dep.symbols.ensure();
|
|
926
|
+
// @ts-expect-error TS2345
|
|
886
927
|
dep.symbols.set('*', '*', convertLoc(loc), true);
|
|
887
928
|
}
|
|
888
929
|
|
|
889
930
|
// Add * symbol if there are CJS exports, no imports/exports at all, or the asset is wrapped.
|
|
890
931
|
// This allows accessing symbols that don't exist without errors in symbol propagation.
|
|
891
|
-
if (symbol_result.has_cjs_exports || !symbol_result.is_esm && deps.size === 0 && symbol_result.exports.length === 0 ||
|
|
932
|
+
if (symbol_result.has_cjs_exports || !symbol_result.is_esm && deps.size === 0 && symbol_result.exports.length === 0 ||
|
|
933
|
+
// @ts-expect-error TS2345
|
|
934
|
+
symbol_result.should_wrap && !asset.symbols.hasExportSymbol('*')) {
|
|
892
935
|
asset.symbols.ensure();
|
|
936
|
+
// @ts-expect-error TS2345
|
|
893
937
|
asset.symbols.set('*', `$${asset.id}$exports`);
|
|
894
938
|
}
|
|
895
939
|
} else {
|
|
896
940
|
// If the asset is wrapped, add * as a fallback
|
|
897
941
|
asset.symbols.ensure();
|
|
942
|
+
// @ts-expect-error TS2345
|
|
898
943
|
asset.symbols.set('*', `$${asset.id}$exports`);
|
|
899
944
|
}
|
|
900
945
|
|
|
@@ -903,6 +948,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
903
948
|
for (let dep of asset.getDependencies()) {
|
|
904
949
|
if (dep.symbols.isCleared) {
|
|
905
950
|
dep.symbols.ensure();
|
|
951
|
+
// @ts-expect-error TS2345
|
|
906
952
|
dep.symbols.set('*', `${dep.id}$`);
|
|
907
953
|
}
|
|
908
954
|
}
|
|
@@ -925,6 +971,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
925
971
|
let sourceMap = new (_sourceMap().default)(options.projectRoot);
|
|
926
972
|
sourceMap.addVLQMap(JSON.parse(map));
|
|
927
973
|
if (originalMap) {
|
|
974
|
+
// @ts-expect-error TS2345
|
|
928
975
|
sourceMap.extends(originalMap);
|
|
929
976
|
}
|
|
930
977
|
asset.setMap(sourceMap);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-js",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.11-typescript-08dcc1c9b.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
12
|
"main": "lib/JSTransformer.js",
|
|
13
|
-
"source": "src/JSTransformer.
|
|
13
|
+
"source": "src/JSTransformer.ts",
|
|
14
14
|
"scripts": {
|
|
15
|
-
"test": "mocha"
|
|
15
|
+
"test": "mocha",
|
|
16
|
+
"check-ts": "tsc --noEmit"
|
|
16
17
|
},
|
|
17
18
|
"engines": {
|
|
18
19
|
"node": ">= 16.0.0"
|
|
@@ -22,13 +23,13 @@
|
|
|
22
23
|
"src"
|
|
23
24
|
],
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@atlaspack/diagnostic": "2.14.
|
|
26
|
-
"@atlaspack/feature-flags": "2.19.
|
|
27
|
-
"@atlaspack/plugin": "2.14.
|
|
28
|
-
"@atlaspack/rust": "3.4.
|
|
26
|
+
"@atlaspack/diagnostic": "2.14.2-typescript-08dcc1c9b.0",
|
|
27
|
+
"@atlaspack/feature-flags": "2.19.3-typescript-08dcc1c9b.0",
|
|
28
|
+
"@atlaspack/plugin": "2.14.21-typescript-08dcc1c9b.0",
|
|
29
|
+
"@atlaspack/rust": "3.4.2-typescript-08dcc1c9b.0",
|
|
30
|
+
"@atlaspack/utils": "2.17.3-typescript-08dcc1c9b.0",
|
|
31
|
+
"@atlaspack/workers": "2.14.21-typescript-08dcc1c9b.0",
|
|
29
32
|
"@parcel/source-map": "^2.1.1",
|
|
30
|
-
"@atlaspack/utils": "2.17.2",
|
|
31
|
-
"@atlaspack/workers": "2.14.20",
|
|
32
33
|
"@swc/helpers": "^0.5.15",
|
|
33
34
|
"browserslist": "^4.6.6",
|
|
34
35
|
"nullthrows": "^1.1.1",
|
|
@@ -38,5 +39,7 @@
|
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"@atlaspack/core": "^2.13.1"
|
|
40
41
|
},
|
|
41
|
-
"type": "commonjs"
|
|
42
|
+
"type": "commonjs",
|
|
43
|
+
"types": "src/JSTransformer.ts",
|
|
44
|
+
"gitHead": "08dcc1c9bcdc6ab931d55e05ccc0f45669de2f22"
|
|
42
45
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import type {
|
|
3
2
|
JSONObject,
|
|
4
3
|
EnvMap,
|
|
@@ -27,7 +26,7 @@ import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
|
27
26
|
const JSX_EXTENSIONS = {
|
|
28
27
|
jsx: true,
|
|
29
28
|
tsx: true,
|
|
30
|
-
};
|
|
29
|
+
} as const;
|
|
31
30
|
|
|
32
31
|
const JSX_PRAGMA = {
|
|
33
32
|
react: {
|
|
@@ -50,7 +49,7 @@ const JSX_PRAGMA = {
|
|
|
50
49
|
pragmaFrag: undefined,
|
|
51
50
|
automatic: undefined,
|
|
52
51
|
},
|
|
53
|
-
};
|
|
52
|
+
} as const;
|
|
54
53
|
|
|
55
54
|
const BROWSER_MAPPING = {
|
|
56
55
|
and_chr: 'chrome',
|
|
@@ -64,7 +63,7 @@ const BROWSER_MAPPING = {
|
|
|
64
63
|
bb: null,
|
|
65
64
|
kaios: null,
|
|
66
65
|
op_mini: null,
|
|
67
|
-
};
|
|
66
|
+
} as const;
|
|
68
67
|
|
|
69
68
|
// List of browsers to exclude when the esmodule target is specified.
|
|
70
69
|
// Based on https://caniuse.com/#feat=es6-module
|
|
@@ -134,45 +133,43 @@ const SCRIPT_ERRORS = {
|
|
|
134
133
|
'Service workers cannot have imports or exports without the `type: "module"` option.',
|
|
135
134
|
hint: "Add {type: 'module'} as a second argument to the navigator.serviceWorker.register() call.",
|
|
136
135
|
},
|
|
137
|
-
};
|
|
136
|
+
} as const;
|
|
138
137
|
|
|
139
138
|
type TSConfig = {
|
|
140
139
|
compilerOptions?: {
|
|
141
140
|
// https://www.typescriptlang.org/tsconfig#jsx
|
|
142
|
-
jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve' | 'react-native'
|
|
141
|
+
jsx?: 'react' | 'react-jsx' | 'react-jsxdev' | 'preserve' | 'react-native';
|
|
143
142
|
// https://www.typescriptlang.org/tsconfig#jsxFactory
|
|
144
|
-
jsxFactory?: string
|
|
143
|
+
jsxFactory?: string;
|
|
145
144
|
// https://www.typescriptlang.org/tsconfig#jsxFragmentFactory
|
|
146
|
-
jsxFragmentFactory?: string
|
|
145
|
+
jsxFragmentFactory?: string;
|
|
147
146
|
// https://www.typescriptlang.org/tsconfig#jsxImportSource
|
|
148
|
-
jsxImportSource?: string
|
|
147
|
+
jsxImportSource?: string;
|
|
149
148
|
// https://www.typescriptlang.org/tsconfig#experimentalDecorators
|
|
150
|
-
experimentalDecorators?: boolean
|
|
149
|
+
experimentalDecorators?: boolean;
|
|
151
150
|
// https://www.typescriptlang.org/tsconfig#useDefineForClassFields
|
|
152
|
-
useDefineForClassFields?: boolean
|
|
151
|
+
useDefineForClassFields?: boolean;
|
|
153
152
|
// https://www.typescriptlang.org/tsconfig#target
|
|
154
|
-
target?: string
|
|
155
|
-
|
|
156
|
-
},
|
|
157
|
-
...
|
|
153
|
+
target?: string; // 'es3' | 'es5' | 'es6' | 'es2015' | ... |'es2022' | ... | 'esnext';
|
|
154
|
+
};
|
|
158
155
|
};
|
|
159
156
|
|
|
160
|
-
type MacroAsset = {
|
|
161
|
-
type: string
|
|
162
|
-
content: string
|
|
163
|
-
|
|
157
|
+
type MacroAsset = {
|
|
158
|
+
type: string;
|
|
159
|
+
content: string;
|
|
160
|
+
};
|
|
164
161
|
|
|
165
162
|
// NOTE: Make sure this is in sync with the TypeScript definition in the @atlaspack/macros package.
|
|
166
|
-
type MacroContext = {
|
|
167
|
-
addAsset(asset: MacroAsset): void
|
|
168
|
-
invalidateOnFileChange(FilePath): void
|
|
169
|
-
invalidateOnFileCreate(FileCreateInvalidation): void
|
|
170
|
-
invalidateOnEnvChange(string): void
|
|
171
|
-
invalidateOnStartup(): void
|
|
172
|
-
invalidateOnBuild(): void
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
export default
|
|
163
|
+
type MacroContext = {
|
|
164
|
+
addAsset(asset: MacroAsset): void;
|
|
165
|
+
invalidateOnFileChange(arg1: FilePath): void;
|
|
166
|
+
invalidateOnFileCreate(arg1: FileCreateInvalidation): void;
|
|
167
|
+
invalidateOnEnvChange(arg1: string): void;
|
|
168
|
+
invalidateOnStartup(): void;
|
|
169
|
+
invalidateOnBuild(): void;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export default new Transformer({
|
|
176
173
|
async loadConfig({config, options}) {
|
|
177
174
|
let packageJson = await config.getPackage();
|
|
178
175
|
let isJSX,
|
|
@@ -220,9 +217,11 @@ export default (new Transformer({
|
|
|
220
217
|
// Use explicitly defined JSX options in tsconfig.json over inferred values from dependencies.
|
|
221
218
|
pragma =
|
|
222
219
|
compilerOptions?.jsxFactory ||
|
|
220
|
+
// @ts-expect-error TS7053
|
|
223
221
|
(reactLib ? JSX_PRAGMA[reactLib].pragma : undefined);
|
|
224
222
|
pragmaFrag =
|
|
225
223
|
compilerOptions?.jsxFragmentFactory ||
|
|
224
|
+
// @ts-expect-error TS7053
|
|
226
225
|
(reactLib ? JSX_PRAGMA[reactLib].pragmaFrag : undefined);
|
|
227
226
|
|
|
228
227
|
if (
|
|
@@ -237,17 +236,20 @@ export default (new Transformer({
|
|
|
237
236
|
packageJson?.alias && packageJson.alias['react'] === 'preact/compat'
|
|
238
237
|
? 'preact'
|
|
239
238
|
: reactLib;
|
|
239
|
+
// @ts-expect-error TS7053
|
|
240
240
|
let automaticVersion = JSX_PRAGMA[effectiveReactLib]?.automatic;
|
|
241
241
|
let reactLibVersion =
|
|
242
242
|
packageJson?.dependencies?.[effectiveReactLib] ||
|
|
243
243
|
packageJson?.devDependencies?.[effectiveReactLib] ||
|
|
244
244
|
packageJson?.peerDependencies?.[effectiveReactLib];
|
|
245
|
+
// @ts-expect-error TS2322
|
|
245
246
|
reactLibVersion = reactLibVersion
|
|
246
247
|
? semver.validRange(reactLibVersion)
|
|
247
248
|
: null;
|
|
248
249
|
let minReactLibVersion =
|
|
249
250
|
reactLibVersion !== null && reactLibVersion !== '*'
|
|
250
|
-
?
|
|
251
|
+
? // @ts-expect-error TS2345
|
|
252
|
+
semver.minVersion(reactLibVersion)?.toString()
|
|
251
253
|
: null;
|
|
252
254
|
|
|
253
255
|
automaticJSXRuntime =
|
|
@@ -312,10 +314,14 @@ export default (new Transformer({
|
|
|
312
314
|
'Invalid config for @atlaspack/transformer-js',
|
|
313
315
|
);
|
|
314
316
|
|
|
317
|
+
// @ts-expect-error TS2339
|
|
315
318
|
magicComments = conf.contents?.magicComments ?? magicComments;
|
|
319
|
+
// @ts-expect-error TS2339
|
|
316
320
|
inlineEnvironment = conf.contents?.inlineEnvironment ?? inlineEnvironment;
|
|
321
|
+
// @ts-expect-error TS2339
|
|
317
322
|
inlineFS = conf.contents?.inlineFS ?? inlineFS;
|
|
318
323
|
inlineConstants =
|
|
324
|
+
// @ts-expect-error TS2339
|
|
319
325
|
conf.contents?.unstable_inlineConstants ?? inlineConstants;
|
|
320
326
|
}
|
|
321
327
|
|
|
@@ -362,6 +368,7 @@ export default (new Transformer({
|
|
|
362
368
|
for (let browser of browsers) {
|
|
363
369
|
let [name, version] = browser.split(' ');
|
|
364
370
|
if (BROWSER_MAPPING.hasOwnProperty(name)) {
|
|
371
|
+
// @ts-expect-error TS7053
|
|
365
372
|
name = BROWSER_MAPPING[name];
|
|
366
373
|
if (!name) {
|
|
367
374
|
continue;
|
|
@@ -371,12 +378,15 @@ export default (new Transformer({
|
|
|
371
378
|
let [major, minor = '0', patch = '0'] = version
|
|
372
379
|
.split('-')[0]
|
|
373
380
|
.split('.');
|
|
381
|
+
// @ts-expect-error TS2345
|
|
374
382
|
if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
|
|
375
383
|
continue;
|
|
376
384
|
}
|
|
377
385
|
let semverVersion = `${major}.${minor}.${patch}`;
|
|
378
386
|
|
|
387
|
+
// @ts-expect-error TS2345
|
|
379
388
|
if (targets[name] == null || semver.gt(targets[name], semverVersion)) {
|
|
389
|
+
// @ts-expect-error TS7053
|
|
380
390
|
targets[name] = semverVersion;
|
|
381
391
|
}
|
|
382
392
|
}
|
|
@@ -386,7 +396,6 @@ export default (new Transformer({
|
|
|
386
396
|
|
|
387
397
|
let env: EnvMap = {};
|
|
388
398
|
|
|
389
|
-
// $FlowFixMe
|
|
390
399
|
if (!config?.inlineEnvironment) {
|
|
391
400
|
if (options.env.NODE_ENV != null) {
|
|
392
401
|
env.NODE_ENV = options.env.NODE_ENV;
|
|
@@ -398,7 +407,6 @@ export default (new Transformer({
|
|
|
398
407
|
} else if (Array.isArray(config?.inlineEnvironment)) {
|
|
399
408
|
for (let match of globMatch(
|
|
400
409
|
Object.keys(options.env),
|
|
401
|
-
// $FlowFixMe
|
|
402
410
|
config.inlineEnvironment,
|
|
403
411
|
)) {
|
|
404
412
|
env[match] = String(options.env[match]);
|
|
@@ -413,30 +421,49 @@ export default (new Transformer({
|
|
|
413
421
|
|
|
414
422
|
let supportsModuleWorkers =
|
|
415
423
|
asset.env.shouldScopeHoist && asset.env.supports('worker-module', true);
|
|
416
|
-
// $FlowFixMe
|
|
417
424
|
let isJSX = Boolean(config?.isJSX);
|
|
418
425
|
if (asset.isSource) {
|
|
419
426
|
if (asset.type === 'ts') {
|
|
420
427
|
isJSX = false;
|
|
421
428
|
} else if (!isJSX) {
|
|
429
|
+
// @ts-expect-error TS7053
|
|
422
430
|
isJSX = Boolean(JSX_EXTENSIONS[asset.type]);
|
|
423
431
|
}
|
|
424
432
|
}
|
|
425
433
|
|
|
426
|
-
let macroAssets
|
|
434
|
+
let macroAssets: Array<{
|
|
435
|
+
content: string;
|
|
436
|
+
// @ts-expect-error TS2552
|
|
437
|
+
map: undefined | NodeSourceMap;
|
|
438
|
+
type: string;
|
|
439
|
+
uniqueKey: string;
|
|
440
|
+
}> = [];
|
|
427
441
|
let {
|
|
442
|
+
// @ts-expect-error TS2339
|
|
428
443
|
dependencies,
|
|
444
|
+
// @ts-expect-error TS2339
|
|
429
445
|
code: compiledCode,
|
|
446
|
+
// @ts-expect-error TS2339
|
|
430
447
|
map,
|
|
448
|
+
// @ts-expect-error TS2339
|
|
431
449
|
shebang,
|
|
450
|
+
// @ts-expect-error TS2339
|
|
432
451
|
hoist_result,
|
|
452
|
+
// @ts-expect-error TS2339
|
|
433
453
|
symbol_result,
|
|
454
|
+
// @ts-expect-error TS2339
|
|
434
455
|
is_empty_or_empty_export,
|
|
456
|
+
// @ts-expect-error TS2339
|
|
435
457
|
needs_esm_helpers,
|
|
458
|
+
// @ts-expect-error TS2339
|
|
436
459
|
diagnostics,
|
|
460
|
+
// @ts-expect-error TS2339
|
|
437
461
|
used_env,
|
|
462
|
+
// @ts-expect-error TS2339
|
|
438
463
|
has_node_replacements,
|
|
464
|
+
// @ts-expect-error TS2339
|
|
439
465
|
is_constant_module,
|
|
466
|
+
// @ts-expect-error TS2339
|
|
440
467
|
conditions,
|
|
441
468
|
} = await (transformAsync || transform)({
|
|
442
469
|
filename: asset.filePath,
|
|
@@ -444,7 +471,6 @@ export default (new Transformer({
|
|
|
444
471
|
module_id: asset.id,
|
|
445
472
|
project_root: options.projectRoot,
|
|
446
473
|
replace_env: !asset.env.isNode(),
|
|
447
|
-
// $FlowFixMe
|
|
448
474
|
inline_fs: Boolean(config?.inlineFS) && !asset.env.isNode(),
|
|
449
475
|
insert_node_globals:
|
|
450
476
|
!asset.env.isNode() && asset.env.sourceType !== 'script',
|
|
@@ -454,13 +480,9 @@ export default (new Transformer({
|
|
|
454
480
|
env,
|
|
455
481
|
is_type_script: asset.type === 'ts' || asset.type === 'tsx',
|
|
456
482
|
is_jsx: isJSX,
|
|
457
|
-
// $FlowFixMe
|
|
458
483
|
jsx_pragma: config?.pragma,
|
|
459
|
-
// $FlowFixMe
|
|
460
484
|
jsx_pragma_frag: config?.pragmaFrag,
|
|
461
|
-
// $FlowFixMe
|
|
462
485
|
automatic_jsx_runtime: Boolean(config?.automaticJSXRuntime),
|
|
463
|
-
// $FlowFixMe
|
|
464
486
|
jsx_import_source: config?.jsxImportSource,
|
|
465
487
|
is_development: options.mode === 'development',
|
|
466
488
|
react_refresh:
|
|
@@ -468,11 +490,8 @@ export default (new Transformer({
|
|
|
468
490
|
!asset.env.isLibrary &&
|
|
469
491
|
!asset.env.isWorker() &&
|
|
470
492
|
!asset.env.isWorklet() &&
|
|
471
|
-
// $FlowFixMe
|
|
472
493
|
Boolean(config?.reactRefresh),
|
|
473
|
-
// $FlowFixMe
|
|
474
494
|
decorators: Boolean(config?.decorators),
|
|
475
|
-
// $FlowFixMe
|
|
476
495
|
use_define_for_class_fields: Boolean(config?.useDefineForClassFields),
|
|
477
496
|
targets,
|
|
478
497
|
source_maps: !!asset.env.sourceMap,
|
|
@@ -485,15 +504,13 @@ export default (new Transformer({
|
|
|
485
504
|
trace_bailouts: options.logLevel === 'verbose',
|
|
486
505
|
is_swc_helpers: /@swc[/\\]helpers/.test(asset.filePath),
|
|
487
506
|
standalone: asset.query.has('standalone'),
|
|
488
|
-
// $FlowFixMe
|
|
489
507
|
inline_constants: config.inlineConstants,
|
|
490
508
|
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
491
509
|
hmr_improvements: options.featureFlags.hmrImprovements,
|
|
492
510
|
computed_properties_fix: options.featureFlags.unusedComputedPropertyFix,
|
|
493
|
-
// $FlowFixMe
|
|
494
511
|
magic_comments: Boolean(config?.magicComments),
|
|
495
512
|
callMacro: asset.isSource
|
|
496
|
-
? async (err, src, exportName, args, loc) => {
|
|
513
|
+
? async (err: any, src: any, exportName: any, args: any, loc: any) => {
|
|
497
514
|
let mod;
|
|
498
515
|
try {
|
|
499
516
|
mod = await options.packageManager.require(src, asset.filePath);
|
|
@@ -502,7 +519,6 @@ export default (new Transformer({
|
|
|
502
519
|
if (
|
|
503
520
|
exportName === 'default' &&
|
|
504
521
|
!mod.__esModule &&
|
|
505
|
-
// $FlowFixMe
|
|
506
522
|
Object.prototype.toString.call(config) !== '[object Module]'
|
|
507
523
|
) {
|
|
508
524
|
mod = {default: mod};
|
|
@@ -511,7 +527,7 @@ export default (new Transformer({
|
|
|
511
527
|
if (!Object.hasOwnProperty.call(mod, exportName)) {
|
|
512
528
|
throw new Error(`"${src}" does not export "${exportName}".`);
|
|
513
529
|
}
|
|
514
|
-
} catch (err) {
|
|
530
|
+
} catch (err: any) {
|
|
515
531
|
throw {
|
|
516
532
|
kind: 1,
|
|
517
533
|
message: err.message,
|
|
@@ -528,7 +544,8 @@ export default (new Transformer({
|
|
|
528
544
|
if (asset.env.sourceMap) {
|
|
529
545
|
// Generate a source map that maps each line of the asset to the original macro call.
|
|
530
546
|
map = new SourceMap(options.projectRoot);
|
|
531
|
-
|
|
547
|
+
// @ts-expect-error TS2304
|
|
548
|
+
let mappings: Array<IndexedMapping<string>> = [];
|
|
532
549
|
let line = 1;
|
|
533
550
|
for (let i = 0; i <= a.content.length; i++) {
|
|
534
551
|
if (i === a.content.length || a.content[i] === '\n') {
|
|
@@ -549,6 +566,7 @@ export default (new Transformer({
|
|
|
549
566
|
|
|
550
567
|
map.addIndexedMappings(mappings);
|
|
551
568
|
if (originalMap) {
|
|
569
|
+
// @ts-expect-error TS2345
|
|
552
570
|
map.extends(originalMap);
|
|
553
571
|
} else {
|
|
554
572
|
map.setSourceContent(asset.filePath, code.toString());
|
|
@@ -567,13 +585,13 @@ export default (new Transformer({
|
|
|
567
585
|
specifierType: 'esm',
|
|
568
586
|
});
|
|
569
587
|
},
|
|
570
|
-
invalidateOnFileChange(filePath) {
|
|
588
|
+
invalidateOnFileChange(filePath: FilePath) {
|
|
571
589
|
asset.invalidateOnFileChange(filePath);
|
|
572
590
|
},
|
|
573
|
-
invalidateOnFileCreate(invalidation) {
|
|
591
|
+
invalidateOnFileCreate(invalidation: FileCreateInvalidation) {
|
|
574
592
|
asset.invalidateOnFileCreate(invalidation);
|
|
575
593
|
},
|
|
576
|
-
invalidateOnEnvChange(env) {
|
|
594
|
+
invalidateOnEnvChange(env: string) {
|
|
577
595
|
asset.invalidateOnEnvChange(env);
|
|
578
596
|
},
|
|
579
597
|
invalidateOnStartup() {
|
|
@@ -590,7 +608,7 @@ export default (new Transformer({
|
|
|
590
608
|
`"${exportName}" in "${src}" is not a function.`,
|
|
591
609
|
);
|
|
592
610
|
}
|
|
593
|
-
} catch (err) {
|
|
611
|
+
} catch (err: any) {
|
|
594
612
|
// Remove atlaspack core from stack and build string so Rust can process errors more easily.
|
|
595
613
|
let stack = (err.stack || '').split('\n').slice(1);
|
|
596
614
|
let message = err.message;
|
|
@@ -610,18 +628,21 @@ export default (new Transformer({
|
|
|
610
628
|
});
|
|
611
629
|
|
|
612
630
|
if (getFeatureFlag('conditionalBundlingApi')) {
|
|
613
|
-
asset.meta.conditions = conditions.map(
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
631
|
+
asset.meta.conditions = conditions.map(
|
|
632
|
+
// @ts-expect-error TS7006
|
|
633
|
+
(c): ConditionMeta => ({
|
|
634
|
+
key: c.key,
|
|
635
|
+
ifTruePlaceholder: c.if_true_placeholder,
|
|
636
|
+
ifFalsePlaceholder: c.if_false_placeholder,
|
|
637
|
+
}),
|
|
638
|
+
);
|
|
618
639
|
}
|
|
619
640
|
|
|
620
641
|
if (is_constant_module) {
|
|
621
642
|
asset.meta.isConstantModule = true;
|
|
622
643
|
}
|
|
623
644
|
|
|
624
|
-
let convertLoc = (loc): SourceLocation => {
|
|
645
|
+
let convertLoc = (loc: any): SourceLocation => {
|
|
625
646
|
let location = {
|
|
626
647
|
filePath: asset.filePath,
|
|
627
648
|
start: {
|
|
@@ -644,19 +665,22 @@ export default (new Transformer({
|
|
|
644
665
|
|
|
645
666
|
if (diagnostics) {
|
|
646
667
|
let errors = diagnostics.filter(
|
|
668
|
+
// @ts-expect-error TS7006
|
|
647
669
|
(d) =>
|
|
648
670
|
d.severity === 'Error' ||
|
|
649
671
|
(d.severity === 'SourceError' && asset.isSource),
|
|
650
672
|
);
|
|
651
673
|
let warnings = diagnostics.filter(
|
|
674
|
+
// @ts-expect-error TS7006
|
|
652
675
|
(d) =>
|
|
653
676
|
d.severity === 'Warning' ||
|
|
654
677
|
(d.severity === 'SourceError' && !asset.isSource),
|
|
655
678
|
);
|
|
656
|
-
let convertDiagnostic = (diagnostic) => {
|
|
679
|
+
let convertDiagnostic = (diagnostic: any) => {
|
|
657
680
|
let message = diagnostic.message;
|
|
658
681
|
if (message === 'SCRIPT_ERROR') {
|
|
659
|
-
|
|
682
|
+
// @ts-expect-error TS7053
|
|
683
|
+
let err = SCRIPT_ERRORS[asset.env.context as string];
|
|
660
684
|
message = err?.message || SCRIPT_ERRORS.browser.message;
|
|
661
685
|
}
|
|
662
686
|
|
|
@@ -665,11 +689,12 @@ export default (new Transformer({
|
|
|
665
689
|
codeFrames: [
|
|
666
690
|
{
|
|
667
691
|
filePath: asset.filePath,
|
|
668
|
-
codeHighlights: diagnostic.code_highlights?.map(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
692
|
+
codeHighlights: diagnostic.code_highlights?.map(
|
|
693
|
+
(highlight: any) =>
|
|
694
|
+
convertSourceLocationToHighlight(
|
|
695
|
+
convertLoc(highlight.loc),
|
|
696
|
+
highlight.message ?? undefined,
|
|
697
|
+
),
|
|
673
698
|
),
|
|
674
699
|
},
|
|
675
700
|
],
|
|
@@ -693,7 +718,8 @@ export default (new Transformer({
|
|
|
693
718
|
});
|
|
694
719
|
}
|
|
695
720
|
|
|
696
|
-
|
|
721
|
+
// @ts-expect-error TS7053
|
|
722
|
+
let err = SCRIPT_ERRORS[asset.env.context as string];
|
|
697
723
|
if (err) {
|
|
698
724
|
if (!res.hints) {
|
|
699
725
|
res.hints = [err.hint];
|
|
@@ -750,6 +776,7 @@ export default (new Transformer({
|
|
|
750
776
|
env: {
|
|
751
777
|
context: 'web-worker',
|
|
752
778
|
sourceType: dep.source_type === 'Module' ? 'module' : 'script',
|
|
779
|
+
// @ts-expect-error TS2322
|
|
753
780
|
outputFormat,
|
|
754
781
|
loc,
|
|
755
782
|
},
|
|
@@ -891,6 +918,7 @@ export default (new Transformer({
|
|
|
891
918
|
idx = dep.specifier.indexOf('/', idx + 1);
|
|
892
919
|
}
|
|
893
920
|
let module = idx >= 0 ? dep.specifier.slice(0, idx) : dep.specifier;
|
|
921
|
+
// @ts-expect-error TS7053
|
|
894
922
|
range = pkg.dependencies[module];
|
|
895
923
|
}
|
|
896
924
|
|
|
@@ -902,12 +930,13 @@ export default (new Transformer({
|
|
|
902
930
|
dep.kind === 'DynamicImport'
|
|
903
931
|
? 'lazy'
|
|
904
932
|
: dep.kind === 'ConditionalImport'
|
|
905
|
-
|
|
906
|
-
|
|
933
|
+
? 'conditional'
|
|
934
|
+
: 'sync',
|
|
907
935
|
isOptional: dep.is_optional,
|
|
908
936
|
meta,
|
|
909
937
|
resolveFrom: isHelper ? __filename : undefined,
|
|
910
938
|
range,
|
|
939
|
+
// @ts-expect-error TS2322
|
|
911
940
|
env,
|
|
912
941
|
});
|
|
913
942
|
}
|
|
@@ -954,12 +983,15 @@ export default (new Transformer({
|
|
|
954
983
|
let dep = deps.get(source);
|
|
955
984
|
if (!dep) continue;
|
|
956
985
|
if (local === '*' && imported === '*') {
|
|
986
|
+
// @ts-expect-error TS2345
|
|
957
987
|
dep.symbols.set('*', '*', convertLoc(loc), true);
|
|
958
988
|
} else {
|
|
959
989
|
let reExportName =
|
|
960
990
|
dep.symbols.get(imported)?.local ??
|
|
961
991
|
`$${asset.id}$re_export$${local}`;
|
|
992
|
+
// @ts-expect-error TS2345
|
|
962
993
|
asset.symbols.set(local, reExportName);
|
|
994
|
+
// @ts-expect-error TS2345
|
|
963
995
|
dep.symbols.set(imported, reExportName, convertLoc(loc), true);
|
|
964
996
|
}
|
|
965
997
|
}
|
|
@@ -982,6 +1014,7 @@ export default (new Transformer({
|
|
|
982
1014
|
// Do not create a self-reference for the `default` symbol unless we have seen an __esModule flag.
|
|
983
1015
|
if (
|
|
984
1016
|
name === 'default' &&
|
|
1017
|
+
// @ts-expect-error TS2345
|
|
985
1018
|
!asset.symbols.hasExportSymbol('__esModule')
|
|
986
1019
|
) {
|
|
987
1020
|
continue;
|
|
@@ -1017,11 +1050,13 @@ export default (new Transformer({
|
|
|
1017
1050
|
asset.sideEffects &&
|
|
1018
1051
|
deps.size === 0 &&
|
|
1019
1052
|
Object.keys(hoist_result.exported_symbols).length === 0) ||
|
|
1053
|
+
// @ts-expect-error TS2345
|
|
1020
1054
|
(hoist_result.should_wrap && !asset.symbols.hasExportSymbol('*'))
|
|
1021
1055
|
) {
|
|
1022
1056
|
if (is_empty_or_empty_export) {
|
|
1023
1057
|
asset.meta.emptyFileStarReexport = true;
|
|
1024
1058
|
}
|
|
1059
|
+
// @ts-expect-error TS2345
|
|
1025
1060
|
asset.symbols.set('*', `$${asset.id}$exports`);
|
|
1026
1061
|
}
|
|
1027
1062
|
|
|
@@ -1041,6 +1076,7 @@ export default (new Transformer({
|
|
|
1041
1076
|
let dep = source ? deps.get(source) : undefined;
|
|
1042
1077
|
asset.symbols.set(
|
|
1043
1078
|
exported,
|
|
1079
|
+
// @ts-expect-error TS2345
|
|
1044
1080
|
`${dep?.id ?? ''}$${local}`,
|
|
1045
1081
|
convertLoc(loc),
|
|
1046
1082
|
);
|
|
@@ -1048,6 +1084,7 @@ export default (new Transformer({
|
|
|
1048
1084
|
dep.symbols.ensure();
|
|
1049
1085
|
dep.symbols.set(
|
|
1050
1086
|
local,
|
|
1087
|
+
// @ts-expect-error TS2345
|
|
1051
1088
|
`${dep?.id ?? ''}$${local}`,
|
|
1052
1089
|
convertLoc(loc),
|
|
1053
1090
|
true,
|
|
@@ -1066,6 +1103,7 @@ export default (new Transformer({
|
|
|
1066
1103
|
let dep = deps.get(source);
|
|
1067
1104
|
if (!dep) continue;
|
|
1068
1105
|
dep.symbols.ensure();
|
|
1106
|
+
// @ts-expect-error TS2345
|
|
1069
1107
|
dep.symbols.set('*', '*', convertLoc(loc), true);
|
|
1070
1108
|
}
|
|
1071
1109
|
|
|
@@ -1076,14 +1114,17 @@ export default (new Transformer({
|
|
|
1076
1114
|
(!symbol_result.is_esm &&
|
|
1077
1115
|
deps.size === 0 &&
|
|
1078
1116
|
symbol_result.exports.length === 0) ||
|
|
1117
|
+
// @ts-expect-error TS2345
|
|
1079
1118
|
(symbol_result.should_wrap && !asset.symbols.hasExportSymbol('*'))
|
|
1080
1119
|
) {
|
|
1081
1120
|
asset.symbols.ensure();
|
|
1121
|
+
// @ts-expect-error TS2345
|
|
1082
1122
|
asset.symbols.set('*', `$${asset.id}$exports`);
|
|
1083
1123
|
}
|
|
1084
1124
|
} else {
|
|
1085
1125
|
// If the asset is wrapped, add * as a fallback
|
|
1086
1126
|
asset.symbols.ensure();
|
|
1127
|
+
// @ts-expect-error TS2345
|
|
1087
1128
|
asset.symbols.set('*', `$${asset.id}$exports`);
|
|
1088
1129
|
}
|
|
1089
1130
|
|
|
@@ -1092,6 +1133,7 @@ export default (new Transformer({
|
|
|
1092
1133
|
for (let dep of asset.getDependencies()) {
|
|
1093
1134
|
if (dep.symbols.isCleared) {
|
|
1094
1135
|
dep.symbols.ensure();
|
|
1136
|
+
// @ts-expect-error TS2345
|
|
1095
1137
|
dep.symbols.set('*', `${dep.id}$`);
|
|
1096
1138
|
}
|
|
1097
1139
|
}
|
|
@@ -1117,6 +1159,7 @@ export default (new Transformer({
|
|
|
1117
1159
|
let sourceMap = new SourceMap(options.projectRoot);
|
|
1118
1160
|
sourceMap.addVLQMap(JSON.parse(map));
|
|
1119
1161
|
if (originalMap) {
|
|
1162
|
+
// @ts-expect-error TS2345
|
|
1120
1163
|
sourceMap.extends(originalMap);
|
|
1121
1164
|
}
|
|
1122
1165
|
asset.setMap(sourceMap);
|
|
@@ -1124,4 +1167,4 @@ export default (new Transformer({
|
|
|
1124
1167
|
|
|
1125
1168
|
return [asset, ...macroAssets];
|
|
1126
1169
|
},
|
|
1127
|
-
})
|
|
1170
|
+
}) as Transformer<unknown>;
|