babel-loader 9.0.1 → 9.1.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/lib/cache.js +12 -7
- package/lib/index.js +3 -1
- package/lib/transform.js +5 -2
- package/package.json +2 -2
package/lib/cache.js
CHANGED
@@ -119,14 +119,19 @@ const handleCache = async function (directory, params) {
|
|
119
119
|
// Otherwise just transform the file
|
120
120
|
// return it to the user asap and write it in cache
|
121
121
|
const result = await transform(source, options);
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
|
123
|
+
// Do not cache if there are external dependencies,
|
124
|
+
// since they might change and we cannot control it.
|
125
|
+
if (!result.externalDependencies.length) {
|
126
|
+
try {
|
127
|
+
await write(file, cacheCompression, result);
|
128
|
+
} catch (err) {
|
129
|
+
if (fallback) {
|
130
|
+
// Fallback to tmpdir if node_modules folder not writable
|
131
|
+
return handleCache(os.tmpdir(), params);
|
132
|
+
}
|
133
|
+
throw err;
|
128
134
|
}
|
129
|
-
throw err;
|
130
135
|
}
|
131
136
|
return result;
|
132
137
|
};
|
package/lib/index.js
CHANGED
@@ -164,8 +164,10 @@ async function loader(source, inputSourceMap, overrides) {
|
|
164
164
|
const {
|
165
165
|
code,
|
166
166
|
map,
|
167
|
-
metadata
|
167
|
+
metadata,
|
168
|
+
externalDependencies
|
168
169
|
} = result;
|
170
|
+
externalDependencies == null ? void 0 : externalDependencies.forEach(dep => this.addDependency(dep));
|
169
171
|
metadataSubscribers.forEach(subscriber => {
|
170
172
|
subscribe(subscriber, metadata, this);
|
171
173
|
});
|
package/lib/transform.js
CHANGED
@@ -25,7 +25,8 @@ module.exports = async function (source, options) {
|
|
25
25
|
code,
|
26
26
|
map,
|
27
27
|
metadata,
|
28
|
-
sourceType
|
28
|
+
sourceType,
|
29
|
+
externalDependencies
|
29
30
|
} = result;
|
30
31
|
if (map && (!map.sourcesContent || !map.sourcesContent.length)) {
|
31
32
|
map.sourcesContent = [source];
|
@@ -35,7 +36,9 @@ module.exports = async function (source, options) {
|
|
35
36
|
code,
|
36
37
|
map,
|
37
38
|
metadata,
|
38
|
-
sourceType
|
39
|
+
sourceType,
|
40
|
+
// Convert it from a Set to an Array to make it JSON-serializable.
|
41
|
+
externalDependencies: Array.from(externalDependencies || [])
|
39
42
|
};
|
40
43
|
};
|
41
44
|
module.exports.version = babel.version;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "babel-loader",
|
3
|
-
"version": "9.0
|
3
|
+
"version": "9.1.0",
|
4
4
|
"description": "babel module loader for webpack",
|
5
5
|
"files": [
|
6
6
|
"lib"
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"react-intl-webpack-plugin": "^0.3.0",
|
43
43
|
"rimraf": "^3.0.0",
|
44
44
|
"semver": "7.3.2",
|
45
|
-
"webpack": "^5.
|
45
|
+
"webpack": "^5.74.0"
|
46
46
|
},
|
47
47
|
"scripts": {
|
48
48
|
"clean": "rimraf lib/",
|