babel-loader 8.3.0 → 8.4.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 +10 -2
- package/lib/index.js +23 -4
- package/package.json +5 -4
package/lib/cache.js
CHANGED
@@ -105,18 +105,24 @@ const handleCache = /*#__PURE__*/function () {
|
|
105
105
|
options = {},
|
106
106
|
cacheIdentifier,
|
107
107
|
cacheDirectory,
|
108
|
-
cacheCompression
|
108
|
+
cacheCompression,
|
109
|
+
logger
|
109
110
|
} = params;
|
110
111
|
const file = path.join(directory, filename(source, cacheIdentifier, options));
|
111
112
|
try {
|
112
113
|
// No errors mean that the file was previously cached
|
113
114
|
// we just need to return it
|
115
|
+
logger.debug(`reading cache file '${file}'`);
|
114
116
|
return yield read(file, cacheCompression);
|
115
|
-
} catch (err) {
|
117
|
+
} catch (err) {
|
118
|
+
// conitnue if cache can't be read
|
119
|
+
logger.debug(`discarded cache as it can not be read`);
|
120
|
+
}
|
116
121
|
const fallback = typeof cacheDirectory !== "string" && directory !== os.tmpdir();
|
117
122
|
|
118
123
|
// Make sure the directory exists.
|
119
124
|
try {
|
125
|
+
logger.debug(`creating cache folder '${directory}'`);
|
120
126
|
yield makeDir(directory);
|
121
127
|
} catch (err) {
|
122
128
|
if (fallback) {
|
@@ -127,12 +133,14 @@ const handleCache = /*#__PURE__*/function () {
|
|
127
133
|
|
128
134
|
// Otherwise just transform the file
|
129
135
|
// return it to the user asap and write it in cache
|
136
|
+
logger.debug(`applying Babel transform`);
|
130
137
|
const result = yield transform(source, options);
|
131
138
|
|
132
139
|
// Do not cache if there are external dependencies,
|
133
140
|
// since they might change and we cannot control it.
|
134
141
|
if (!result.externalDependencies.length) {
|
135
142
|
try {
|
143
|
+
logger.debug(`writing result to cache file '${file}'`);
|
136
144
|
yield write(file, cacheCompression, result);
|
137
145
|
} catch (err) {
|
138
146
|
if (fallback) {
|
package/lib/index.js
CHANGED
@@ -50,6 +50,7 @@ function loader(_x, _x2, _x3) {
|
|
50
50
|
function _loader() {
|
51
51
|
_loader = _asyncToGenerator(function* (source, inputSourceMap, overrides) {
|
52
52
|
const filename = this.resourcePath;
|
53
|
+
const logger = this.getLogger("babel-loader");
|
53
54
|
let loaderOptions = loaderUtils.getOptions(this);
|
54
55
|
validateOptions(schema, loaderOptions, {
|
55
56
|
name: "Babel loader"
|
@@ -64,15 +65,18 @@ function _loader() {
|
|
64
65
|
if (overrides) {
|
65
66
|
throw new Error("babel-loader's 'customize' option is not available when already " + "using a customized babel-loader wrapper.");
|
66
67
|
}
|
68
|
+
logger.debug(`loading customize override: '${loaderOptions.customize}'`);
|
67
69
|
let override = require(loaderOptions.customize);
|
68
70
|
if (override.__esModule) override = override.default;
|
69
71
|
if (typeof override !== "function") {
|
70
72
|
throw new Error("Custom overrides must be functions.");
|
71
73
|
}
|
74
|
+
logger.debug("applying customize override to @babel/core");
|
72
75
|
overrides = override(babel);
|
73
76
|
}
|
74
77
|
let customOptions;
|
75
78
|
if (overrides && overrides.customOptions) {
|
79
|
+
logger.debug("applying overrides customOptions() to loader options");
|
76
80
|
const result = yield overrides.customOptions.call(this, loaderOptions, {
|
77
81
|
source,
|
78
82
|
map: inputSourceMap
|
@@ -88,7 +92,7 @@ function _loader() {
|
|
88
92
|
if (typeof loaderOptions.babelrc === "string") {
|
89
93
|
console.warn("The option `babelrc` should not be set to a string anymore in the babel-loader config. " + "Please update your configuration and set `babelrc` to true or false.\n" + "If you want to specify a specific babel config file to inherit config from " + "please use the `extends` option.\nFor more information about this options see " + "https://babeljs.io/docs/core-packages/#options");
|
90
94
|
}
|
91
|
-
|
95
|
+
logger.debug("normalizing loader options");
|
92
96
|
// Standardize on 'sourceMaps' as the key passed through to Webpack, so that
|
93
97
|
// users may safely use either one alongside our default use of
|
94
98
|
// 'this.sourceMap' below without getting error about conflicting aliases.
|
@@ -123,10 +127,12 @@ function _loader() {
|
|
123
127
|
const {
|
124
128
|
loadPartialConfigAsync = babel.loadPartialConfig
|
125
129
|
} = babel;
|
130
|
+
logger.debug("resolving Babel configs");
|
126
131
|
const config = yield loadPartialConfigAsync(injectCaller(programmaticOptions, this.target));
|
127
132
|
if (config) {
|
128
133
|
let options = config.options;
|
129
134
|
if (overrides && overrides.config) {
|
135
|
+
logger.debug("applying overrides config() to Babel config");
|
130
136
|
options = yield overrides.config.call(this, config, {
|
131
137
|
source,
|
132
138
|
map: inputSourceMap,
|
@@ -154,34 +160,43 @@ function _loader() {
|
|
154
160
|
} = loaderOptions;
|
155
161
|
let result;
|
156
162
|
if (cacheDirectory) {
|
163
|
+
logger.debug("cache is enabled");
|
157
164
|
result = yield cache({
|
158
165
|
source,
|
159
166
|
options,
|
160
167
|
transform,
|
161
168
|
cacheDirectory,
|
162
169
|
cacheIdentifier,
|
163
|
-
cacheCompression
|
170
|
+
cacheCompression,
|
171
|
+
logger
|
164
172
|
});
|
165
173
|
} else {
|
174
|
+
logger.debug("cache is disabled, applying Babel transform");
|
166
175
|
result = yield transform(source, options);
|
167
176
|
}
|
168
177
|
|
169
178
|
// Availabe since Babel 7.12
|
170
179
|
// https://github.com/babel/babel/pull/11907
|
171
180
|
if (config.files) {
|
172
|
-
config.files.forEach(configFile =>
|
181
|
+
config.files.forEach(configFile => {
|
182
|
+
this.addDependency(configFile);
|
183
|
+
logger.debug(`added '${configFile}' to webpack dependencies`);
|
184
|
+
});
|
173
185
|
} else {
|
174
186
|
// .babelrc.json
|
175
187
|
if (typeof config.babelrc === "string") {
|
176
188
|
this.addDependency(config.babelrc);
|
189
|
+
logger.debug(`added '${config.babelrc}' to webpack dependencies`);
|
177
190
|
}
|
178
191
|
// babel.config.js
|
179
192
|
if (config.config) {
|
180
193
|
this.addDependency(config.config);
|
194
|
+
logger.debug(`added '${config.config}' to webpack dependencies`);
|
181
195
|
}
|
182
196
|
}
|
183
197
|
if (result) {
|
184
198
|
if (overrides && overrides.result) {
|
199
|
+
logger.debug("applying overrides result() to Babel transform results");
|
185
200
|
result = yield overrides.result.call(this, result, {
|
186
201
|
source,
|
187
202
|
map: inputSourceMap,
|
@@ -196,9 +211,13 @@ function _loader() {
|
|
196
211
|
metadata,
|
197
212
|
externalDependencies
|
198
213
|
} = result;
|
199
|
-
externalDependencies == null ? void 0 : externalDependencies.forEach(dep =>
|
214
|
+
externalDependencies == null ? void 0 : externalDependencies.forEach(dep => {
|
215
|
+
this.addDependency(dep);
|
216
|
+
logger.debug(`added '${dep}' to webpack dependencies`);
|
217
|
+
});
|
200
218
|
metadataSubscribers.forEach(subscriber => {
|
201
219
|
subscribe(subscriber, metadata, this);
|
220
|
+
logger.debug(`invoked metadata subscriber '${String(subscriber)}'`);
|
202
221
|
});
|
203
222
|
return [code, map];
|
204
223
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "babel-loader",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.4.0",
|
4
4
|
"description": "babel module loader for webpack",
|
5
5
|
"files": [
|
6
6
|
"lib"
|
@@ -11,7 +11,7 @@
|
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
13
|
"find-cache-dir": "^3.3.1",
|
14
|
-
"loader-utils": "^2.0.
|
14
|
+
"loader-utils": "^2.0.4",
|
15
15
|
"make-dir": "^3.1.0",
|
16
16
|
"schema-utils": "^2.6.5"
|
17
17
|
},
|
@@ -44,7 +44,7 @@
|
|
44
44
|
"react-intl-webpack-plugin": "^0.3.0",
|
45
45
|
"rimraf": "^3.0.0",
|
46
46
|
"semver": "7.3.2",
|
47
|
-
"webpack": "^5.
|
47
|
+
"webpack": "^5.61.0"
|
48
48
|
},
|
49
49
|
"scripts": {
|
50
50
|
"clean": "rimraf lib/",
|
@@ -123,5 +123,6 @@
|
|
123
123
|
},
|
124
124
|
"resolutions": {
|
125
125
|
"nyc/node-preload": "0.2.0"
|
126
|
-
}
|
126
|
+
},
|
127
|
+
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
127
128
|
}
|