@atlaspack/optimizer-inline-requires 2.12.1-dev.3401 → 2.12.1-dev.3443
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/lib/InlineRequires.js +34 -0
- package/package.json +8 -6
- package/src/InlineRequires.js +22 -0
package/lib/InlineRequires.js
CHANGED
|
@@ -7,6 +7,20 @@ function _plugin() {
|
|
|
7
7
|
};
|
|
8
8
|
return data;
|
|
9
9
|
}
|
|
10
|
+
function _featureFlags() {
|
|
11
|
+
const data = require("@atlaspack/feature-flags");
|
|
12
|
+
_featureFlags = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _rust() {
|
|
18
|
+
const data = require("@atlaspack/rust");
|
|
19
|
+
_rust = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
10
24
|
function _core() {
|
|
11
25
|
const data = require("@swc/core");
|
|
12
26
|
_core = function () {
|
|
@@ -78,6 +92,26 @@ module.exports = new (_plugin().Optimizer)({
|
|
|
78
92
|
};
|
|
79
93
|
}
|
|
80
94
|
try {
|
|
95
|
+
if ((0, _featureFlags().getFeatureFlag)('fastOptimizeInlineRequires')) {
|
|
96
|
+
let sourceMap = null;
|
|
97
|
+
const result = (0, _rust().runInlineRequiresOptimizer)({
|
|
98
|
+
code: contents.toString(),
|
|
99
|
+
sourceMaps: !!bundle.env.sourceMap,
|
|
100
|
+
ignoreModuleIds: Array.from(bundleConfig.assetPublicIdsWithSideEffects)
|
|
101
|
+
});
|
|
102
|
+
const sourceMapResult = result.sourceMap;
|
|
103
|
+
if (sourceMapResult != null) {
|
|
104
|
+
sourceMap = new (_sourceMap().default)(options.projectRoot);
|
|
105
|
+
sourceMap.addVLQMap(JSON.parse(sourceMapResult));
|
|
106
|
+
if (originalMap) {
|
|
107
|
+
sourceMap.extends(originalMap);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
contents: result.code,
|
|
112
|
+
map: originalMap
|
|
113
|
+
};
|
|
114
|
+
}
|
|
81
115
|
let measurement = tracer.createMeasurement('@atlaspack/optimizer-inline-requires', 'parse', bundle.name);
|
|
82
116
|
const ast = await (0, _core().parse)(contents.toString());
|
|
83
117
|
measurement && measurement.end();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/optimizer-inline-requires",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "2.12.1-dev.3443+d1170cfc7",
|
|
4
|
+
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -13,14 +13,16 @@
|
|
|
13
13
|
"source": "src/InlineRequires.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">= 14.0.0",
|
|
16
|
-
"parcel": "^2.12.1-dev.
|
|
16
|
+
"parcel": "^2.12.1-dev.3443+d1170cfc7"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/
|
|
20
|
-
"@atlaspack/
|
|
19
|
+
"@atlaspack/feature-flags": "2.12.1-dev.3443+d1170cfc7",
|
|
20
|
+
"@atlaspack/plugin": "2.12.1-dev.3443+d1170cfc7",
|
|
21
|
+
"@atlaspack/rust": "2.12.1-dev.3443+d1170cfc7",
|
|
22
|
+
"@atlaspack/types": "2.12.1-dev.3443+d1170cfc7",
|
|
21
23
|
"@parcel/source-map": "^2.1.1",
|
|
22
24
|
"@swc/core": "^1.3.36",
|
|
23
25
|
"nullthrows": "^1.1.1"
|
|
24
26
|
},
|
|
25
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "d1170cfc79beb290b2a066f472f68f71f7d7cb23"
|
|
26
28
|
}
|
package/src/InlineRequires.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
import {Optimizer} from '@atlaspack/plugin';
|
|
3
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
4
|
+
import {runInlineRequiresOptimizer} from '@atlaspack/rust';
|
|
3
5
|
import {parse, print} from '@swc/core';
|
|
4
6
|
import {RequireInliningVisitor} from './RequireInliningVisitor';
|
|
5
7
|
import nullthrows from 'nullthrows';
|
|
@@ -57,6 +59,26 @@ module.exports = new Optimizer<empty, BundleConfig>({
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
try {
|
|
62
|
+
if (getFeatureFlag('fastOptimizeInlineRequires')) {
|
|
63
|
+
let sourceMap = null;
|
|
64
|
+
const result = runInlineRequiresOptimizer({
|
|
65
|
+
code: contents.toString(),
|
|
66
|
+
sourceMaps: !!bundle.env.sourceMap,
|
|
67
|
+
ignoreModuleIds: Array.from(
|
|
68
|
+
bundleConfig.assetPublicIdsWithSideEffects,
|
|
69
|
+
),
|
|
70
|
+
});
|
|
71
|
+
const sourceMapResult = result.sourceMap;
|
|
72
|
+
if (sourceMapResult != null) {
|
|
73
|
+
sourceMap = new SourceMap(options.projectRoot);
|
|
74
|
+
sourceMap.addVLQMap(JSON.parse(sourceMapResult));
|
|
75
|
+
if (originalMap) {
|
|
76
|
+
sourceMap.extends(originalMap);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {contents: result.code, map: originalMap};
|
|
80
|
+
}
|
|
81
|
+
|
|
60
82
|
let measurement = tracer.createMeasurement(
|
|
61
83
|
'@atlaspack/optimizer-inline-requires',
|
|
62
84
|
'parse',
|