babel-loader 8.3.0 → 8.4.1

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 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,9 @@ 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 = typeof this.getLogger === "function" ? this.getLogger("babel-loader") : {
54
+ debug: () => {}
55
+ };
53
56
  let loaderOptions = loaderUtils.getOptions(this);
54
57
  validateOptions(schema, loaderOptions, {
55
58
  name: "Babel loader"
@@ -64,15 +67,18 @@ function _loader() {
64
67
  if (overrides) {
65
68
  throw new Error("babel-loader's 'customize' option is not available when already " + "using a customized babel-loader wrapper.");
66
69
  }
70
+ logger.debug(`loading customize override: '${loaderOptions.customize}'`);
67
71
  let override = require(loaderOptions.customize);
68
72
  if (override.__esModule) override = override.default;
69
73
  if (typeof override !== "function") {
70
74
  throw new Error("Custom overrides must be functions.");
71
75
  }
76
+ logger.debug("applying customize override to @babel/core");
72
77
  overrides = override(babel);
73
78
  }
74
79
  let customOptions;
75
80
  if (overrides && overrides.customOptions) {
81
+ logger.debug("applying overrides customOptions() to loader options");
76
82
  const result = yield overrides.customOptions.call(this, loaderOptions, {
77
83
  source,
78
84
  map: inputSourceMap
@@ -88,7 +94,7 @@ function _loader() {
88
94
  if (typeof loaderOptions.babelrc === "string") {
89
95
  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
96
  }
91
-
97
+ logger.debug("normalizing loader options");
92
98
  // Standardize on 'sourceMaps' as the key passed through to Webpack, so that
93
99
  // users may safely use either one alongside our default use of
94
100
  // 'this.sourceMap' below without getting error about conflicting aliases.
@@ -123,10 +129,12 @@ function _loader() {
123
129
  const {
124
130
  loadPartialConfigAsync = babel.loadPartialConfig
125
131
  } = babel;
132
+ logger.debug("resolving Babel configs");
126
133
  const config = yield loadPartialConfigAsync(injectCaller(programmaticOptions, this.target));
127
134
  if (config) {
128
135
  let options = config.options;
129
136
  if (overrides && overrides.config) {
137
+ logger.debug("applying overrides config() to Babel config");
130
138
  options = yield overrides.config.call(this, config, {
131
139
  source,
132
140
  map: inputSourceMap,
@@ -154,34 +162,43 @@ function _loader() {
154
162
  } = loaderOptions;
155
163
  let result;
156
164
  if (cacheDirectory) {
165
+ logger.debug("cache is enabled");
157
166
  result = yield cache({
158
167
  source,
159
168
  options,
160
169
  transform,
161
170
  cacheDirectory,
162
171
  cacheIdentifier,
163
- cacheCompression
172
+ cacheCompression,
173
+ logger
164
174
  });
165
175
  } else {
176
+ logger.debug("cache is disabled, applying Babel transform");
166
177
  result = yield transform(source, options);
167
178
  }
168
179
 
169
180
  // Availabe since Babel 7.12
170
181
  // https://github.com/babel/babel/pull/11907
171
182
  if (config.files) {
172
- config.files.forEach(configFile => this.addDependency(configFile));
183
+ config.files.forEach(configFile => {
184
+ this.addDependency(configFile);
185
+ logger.debug(`added '${configFile}' to webpack dependencies`);
186
+ });
173
187
  } else {
174
188
  // .babelrc.json
175
189
  if (typeof config.babelrc === "string") {
176
190
  this.addDependency(config.babelrc);
191
+ logger.debug(`added '${config.babelrc}' to webpack dependencies`);
177
192
  }
178
193
  // babel.config.js
179
194
  if (config.config) {
180
195
  this.addDependency(config.config);
196
+ logger.debug(`added '${config.config}' to webpack dependencies`);
181
197
  }
182
198
  }
183
199
  if (result) {
184
200
  if (overrides && overrides.result) {
201
+ logger.debug("applying overrides result() to Babel transform results");
185
202
  result = yield overrides.result.call(this, result, {
186
203
  source,
187
204
  map: inputSourceMap,
@@ -196,9 +213,13 @@ function _loader() {
196
213
  metadata,
197
214
  externalDependencies
198
215
  } = result;
199
- externalDependencies == null ? void 0 : externalDependencies.forEach(dep => this.addDependency(dep));
216
+ externalDependencies == null ? void 0 : externalDependencies.forEach(dep => {
217
+ this.addDependency(dep);
218
+ logger.debug(`added '${dep}' to webpack dependencies`);
219
+ });
200
220
  metadataSubscribers.forEach(subscriber => {
201
221
  subscribe(subscriber, metadata, this);
222
+ logger.debug(`invoked metadata subscriber '${String(subscriber)}'`);
202
223
  });
203
224
  return [code, map];
204
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-loader",
3
- "version": "8.3.0",
3
+ "version": "8.4.1",
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.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.34.0"
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
  }