@parcel/transformer-babel 2.0.0-nightly.1267 → 2.0.0-nightly.1273

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.
@@ -71,6 +71,7 @@ var _default = new (_plugin().Transformer)({
71
71
  async transform({
72
72
  asset,
73
73
  config,
74
+ logger,
74
75
  options
75
76
  }) {
76
77
  try {
@@ -79,6 +80,7 @@ var _default = new (_plugin().Transformer)({
79
80
  await (0, _babel.default)({
80
81
  asset,
81
82
  options,
83
+ logger,
82
84
  babelOptions: config,
83
85
  additionalPlugins: asset.meta.babelPlugins
84
86
  });
@@ -86,6 +88,7 @@ var _default = new (_plugin().Transformer)({
86
88
  await (0, _babel.default)({
87
89
  asset,
88
90
  options,
91
+ logger,
89
92
  babelOptions: config
90
93
  });
91
94
  }
package/lib/babel7.js CHANGED
@@ -15,6 +15,26 @@ function _assert() {
15
15
  return data;
16
16
  }
17
17
 
18
+ function _path() {
19
+ const data = _interopRequireDefault(require("path"));
20
+
21
+ _path = function () {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _diagnostic() {
29
+ const data = require("@parcel/diagnostic");
30
+
31
+ _diagnostic = function () {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
18
38
  function _utils() {
19
39
  const data = require("@parcel/utils");
20
40
 
@@ -86,6 +106,25 @@ async function babel7(opts) {
86
106
  (0, _remapAstLocations.remapAstLocations)(babelCore.types, res.ast, map);
87
107
  }
88
108
  }
109
+
110
+ if (res.externalDependencies) {
111
+ for (let f of res.externalDependencies) {
112
+ if (!_path().default.isAbsolute(f)) {
113
+ opts.logger.warn({
114
+ message: (0, _diagnostic().md)`Ignoring non-absolute Babel external dependency: ${f}`,
115
+ hints: ['Please report this to the corresponding Babel plugin and/or to Parcel.']
116
+ });
117
+ } else {
118
+ if (await options.inputFS.exists(f)) {
119
+ asset.invalidateOnFileChange(f);
120
+ } else {
121
+ asset.invalidateOnFileCreate({
122
+ filePath: f
123
+ });
124
+ }
125
+ }
126
+ }
127
+ }
89
128
  }
90
129
 
91
130
  if (res.ast) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/transformer-babel",
3
- "version": "2.0.0-nightly.1267+9e6d0080d",
3
+ "version": "2.0.0-nightly.1273+f65889ebd",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,13 +17,13 @@
17
17
  "source": "src/BabelTransformer.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "2.0.0-nightly.1265+9e6d0080d"
20
+ "parcel": "2.0.0-nightly.1271+f65889ebd"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/diagnostic": "2.0.0-nightly.1267+9e6d0080d",
24
- "@parcel/plugin": "2.0.0-nightly.1267+9e6d0080d",
23
+ "@parcel/diagnostic": "2.0.0-nightly.1273+f65889ebd",
24
+ "@parcel/plugin": "2.0.0-nightly.1273+f65889ebd",
25
25
  "@parcel/source-map": "^2.1.1",
26
- "@parcel/utils": "2.0.0-nightly.1267+9e6d0080d",
26
+ "@parcel/utils": "2.0.0-nightly.1273+f65889ebd",
27
27
  "browserslist": "^4.6.6",
28
28
  "json5": "^2.2.0",
29
29
  "nullthrows": "^1.1.1",
@@ -33,7 +33,7 @@
33
33
  "@babel/core": "^7.12.0",
34
34
  "@babel/preset-env": "^7.0.0",
35
35
  "@babel/types": "^7.12.0",
36
- "@parcel/types": "2.0.0-nightly.1267+9e6d0080d"
36
+ "@parcel/types": "2.0.0-nightly.1273+f65889ebd"
37
37
  },
38
- "gitHead": "9e6d0080d9d017c343b6199f54f867ee992b352d"
38
+ "gitHead": "f65889ebd768e9b2e146537b47d4d5d82ff177b8"
39
39
  }
@@ -17,7 +17,7 @@ export default (new Transformer({
17
17
  return ast.type === 'babel' && semver.satisfies(ast.version, '^7.0.0');
18
18
  },
19
19
 
20
- async transform({asset, config, options}) {
20
+ async transform({asset, config, logger, options}) {
21
21
  try {
22
22
  if (config?.config) {
23
23
  if (
@@ -27,11 +27,12 @@ export default (new Transformer({
27
27
  await babel7({
28
28
  asset,
29
29
  options,
30
+ logger,
30
31
  babelOptions: config,
31
32
  additionalPlugins: asset.meta.babelPlugins,
32
33
  });
33
34
  } else {
34
- await babel7({asset, options, babelOptions: config});
35
+ await babel7({asset, options, logger, babelOptions: config});
35
36
  }
36
37
  }
37
38
 
package/src/babel7.js CHANGED
@@ -1,9 +1,16 @@
1
1
  // @flow
2
2
 
3
- import type {MutableAsset, AST, PluginOptions} from '@parcel/types';
3
+ import type {
4
+ MutableAsset,
5
+ AST,
6
+ PluginOptions,
7
+ PluginLogger,
8
+ } from '@parcel/types';
4
9
  import typeof * as BabelCore from '@babel/core';
5
10
 
6
11
  import invariant from 'assert';
12
+ import path from 'path';
13
+ import {md} from '@parcel/diagnostic';
7
14
  import {relativeUrl} from '@parcel/utils';
8
15
  import {remapAstLocations} from './remapAstLocations';
9
16
 
@@ -15,6 +22,7 @@ invariant(typeof transformerVersion === 'string');
15
22
  type Babel7TransformOptions = {|
16
23
  asset: MutableAsset,
17
24
  options: PluginOptions,
25
+ logger: PluginLogger,
18
26
  babelOptions: any,
19
27
  additionalPlugins?: Array<any>,
20
28
  |};
@@ -82,6 +90,24 @@ export default async function babel7(
82
90
  remapAstLocations(babelCore.types, res.ast, map);
83
91
  }
84
92
  }
93
+ if (res.externalDependencies) {
94
+ for (let f of res.externalDependencies) {
95
+ if (!path.isAbsolute(f)) {
96
+ opts.logger.warn({
97
+ message: md`Ignoring non-absolute Babel external dependency: ${f}`,
98
+ hints: [
99
+ 'Please report this to the corresponding Babel plugin and/or to Parcel.',
100
+ ],
101
+ });
102
+ } else {
103
+ if (await options.inputFS.exists(f)) {
104
+ asset.invalidateOnFileChange(f);
105
+ } else {
106
+ asset.invalidateOnFileCreate({filePath: f});
107
+ }
108
+ }
109
+ }
110
+ }
85
111
  }
86
112
 
87
113
  if (res.ast) {