@parcel/transformer-babel 2.0.0-nightly.861 → 2.0.0-nightly.875
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/config.js +21 -5
- package/package.json +8 -7
- package/src/config.js +11 -5
package/lib/config.js
CHANGED
|
@@ -5,6 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.load = load;
|
|
7
7
|
|
|
8
|
+
function _json() {
|
|
9
|
+
const data = _interopRequireDefault(require("json5"));
|
|
10
|
+
|
|
11
|
+
_json = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
function _path() {
|
|
9
19
|
const data = _interopRequireDefault(require("path"));
|
|
10
20
|
|
|
@@ -309,7 +319,7 @@ async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
|
309
319
|
codeHighlights: await getCodeHighlights(fs, configPath, foundRedundantPresets)
|
|
310
320
|
}],
|
|
311
321
|
hints: [(0, _diagnostic().md)`Delete __${filePath}__`],
|
|
312
|
-
documentationURL: 'https://
|
|
322
|
+
documentationURL: 'https://parceljs.org/languages/javascript/#default-presets'
|
|
313
323
|
});
|
|
314
324
|
} else if (foundRedundantPresets.size > 0) {
|
|
315
325
|
diagnostics.push({
|
|
@@ -319,7 +329,7 @@ async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
|
319
329
|
codeHighlights: await getCodeHighlights(fs, configPath, foundRedundantPresets)
|
|
320
330
|
}],
|
|
321
331
|
hints: [(0, _diagnostic().md)`Remove the above presets from __${filePath}__`],
|
|
322
|
-
documentationURL: 'https://
|
|
332
|
+
documentationURL: 'https://parceljs.org/languages/javascript/#default-presets'
|
|
323
333
|
});
|
|
324
334
|
}
|
|
325
335
|
|
|
@@ -333,7 +343,7 @@ async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
|
333
343
|
codeHighlights: await getCodeHighlights(fs, (_babelConfig$config3 = babelConfig.config) !== null && _babelConfig$config3 !== void 0 ? _babelConfig$config3 : babelConfig.babelrc, new Set(['@babel/preset-env']))
|
|
334
344
|
}],
|
|
335
345
|
hints: [`Either remove __@babel/preset-env__ to use Parcel's builtin transpilation, or replace with __@parcel/babel-preset-env__`],
|
|
336
|
-
documentationURL: 'https://
|
|
346
|
+
documentationURL: 'https://parceljs.org/languages/javascript/#custom-plugins'
|
|
337
347
|
});
|
|
338
348
|
}
|
|
339
349
|
|
|
@@ -347,7 +357,9 @@ async function getCodeHighlights(fs, filePath, redundantPresets) {
|
|
|
347
357
|
|
|
348
358
|
if (ext !== '.js' && ext !== '.cjs' && ext !== '.mjs') {
|
|
349
359
|
let contents = await fs.readFile(filePath, 'utf8');
|
|
350
|
-
|
|
360
|
+
|
|
361
|
+
let json = _json().default.parse(contents);
|
|
362
|
+
|
|
351
363
|
let presets = json.presets || [];
|
|
352
364
|
let pointers = [];
|
|
353
365
|
|
|
@@ -366,7 +378,11 @@ async function getCodeHighlights(fs, filePath, redundantPresets) {
|
|
|
366
378
|
}
|
|
367
379
|
|
|
368
380
|
if (pointers.length > 0) {
|
|
369
|
-
|
|
381
|
+
try {
|
|
382
|
+
return (0, _diagnostic().generateJSONCodeHighlights)(contents, pointers);
|
|
383
|
+
} catch {// TODO: support code highlights for json5 sources.
|
|
384
|
+
// Babel supports json5 syntax, but json-source-map does not.
|
|
385
|
+
}
|
|
370
386
|
}
|
|
371
387
|
}
|
|
372
388
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/transformer-babel",
|
|
3
|
-
"version": "2.0.0-nightly.
|
|
3
|
+
"version": "2.0.0-nightly.875+d6de61d3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,20 +25,21 @@
|
|
|
25
25
|
"@babel/helper-compilation-targets": "^7.8.4",
|
|
26
26
|
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
|
|
27
27
|
"@babel/traverse": "^7.0.0",
|
|
28
|
-
"@parcel/babel-ast-utils": "2.0.0-nightly.
|
|
29
|
-
"@parcel/diagnostic": "2.0.0-nightly.
|
|
30
|
-
"@parcel/plugin": "2.0.0-nightly.
|
|
28
|
+
"@parcel/babel-ast-utils": "2.0.0-nightly.2497+d6de61d3",
|
|
29
|
+
"@parcel/diagnostic": "2.0.0-nightly.875+d6de61d3",
|
|
30
|
+
"@parcel/plugin": "2.0.0-nightly.875+d6de61d3",
|
|
31
31
|
"@parcel/source-map": "2.0.0-rc.7",
|
|
32
|
-
"@parcel/utils": "2.0.0-nightly.
|
|
32
|
+
"@parcel/utils": "2.0.0-nightly.875+d6de61d3",
|
|
33
33
|
"browserslist": "^4.6.6",
|
|
34
34
|
"core-js": "^3.2.1",
|
|
35
|
+
"json5": "^2.1.0",
|
|
35
36
|
"nullthrows": "^1.1.1",
|
|
36
37
|
"semver": "^5.7.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@babel/core": "^7.12.0",
|
|
40
41
|
"@babel/preset-env": "^7.0.0",
|
|
41
|
-
"@parcel/types": "2.0.0-nightly.
|
|
42
|
+
"@parcel/types": "2.0.0-nightly.875+d6de61d3"
|
|
42
43
|
},
|
|
43
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "d6de61d33450c753d5bb30d06426b35a4674a98b"
|
|
44
45
|
}
|
package/src/config.js
CHANGED
|
@@ -5,6 +5,7 @@ import typeof * as BabelCore from '@babel/core';
|
|
|
5
5
|
import type {Diagnostic} from '@parcel/diagnostic';
|
|
6
6
|
import type {BabelConfig} from './types';
|
|
7
7
|
|
|
8
|
+
import json5 from 'json5';
|
|
8
9
|
import path from 'path';
|
|
9
10
|
import * as internalBabelCore from '@babel/core';
|
|
10
11
|
import {hashObject, relativePath, resolveConfig} from '@parcel/utils';
|
|
@@ -341,7 +342,7 @@ async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
|
341
342
|
],
|
|
342
343
|
hints: [md`Delete __${filePath}__`],
|
|
343
344
|
documentationURL:
|
|
344
|
-
'https://
|
|
345
|
+
'https://parceljs.org/languages/javascript/#default-presets',
|
|
345
346
|
});
|
|
346
347
|
} else if (foundRedundantPresets.size > 0) {
|
|
347
348
|
diagnostics.push({
|
|
@@ -362,7 +363,7 @@ async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
|
362
363
|
],
|
|
363
364
|
hints: [md`Remove the above presets from __${filePath}__`],
|
|
364
365
|
documentationURL:
|
|
365
|
-
'https://
|
|
366
|
+
'https://parceljs.org/languages/javascript/#default-presets',
|
|
366
367
|
});
|
|
367
368
|
}
|
|
368
369
|
|
|
@@ -384,7 +385,7 @@ async function warnOnRedundantPlugins(fs, babelConfig, logger) {
|
|
|
384
385
|
`Either remove __@babel/preset-env__ to use Parcel's builtin transpilation, or replace with __@parcel/babel-preset-env__`,
|
|
385
386
|
],
|
|
386
387
|
documentationURL:
|
|
387
|
-
'https://
|
|
388
|
+
'https://parceljs.org/languages/javascript/#custom-plugins',
|
|
388
389
|
});
|
|
389
390
|
}
|
|
390
391
|
|
|
@@ -397,7 +398,7 @@ async function getCodeHighlights(fs, filePath, redundantPresets) {
|
|
|
397
398
|
let ext = path.extname(filePath);
|
|
398
399
|
if (ext !== '.js' && ext !== '.cjs' && ext !== '.mjs') {
|
|
399
400
|
let contents = await fs.readFile(filePath, 'utf8');
|
|
400
|
-
let json =
|
|
401
|
+
let json = json5.parse(contents);
|
|
401
402
|
|
|
402
403
|
let presets = json.presets || [];
|
|
403
404
|
let pointers = [];
|
|
@@ -410,7 +411,12 @@ async function getCodeHighlights(fs, filePath, redundantPresets) {
|
|
|
410
411
|
}
|
|
411
412
|
|
|
412
413
|
if (pointers.length > 0) {
|
|
413
|
-
|
|
414
|
+
try {
|
|
415
|
+
return generateJSONCodeHighlights(contents, pointers);
|
|
416
|
+
} catch {
|
|
417
|
+
// TODO: support code highlights for json5 sources.
|
|
418
|
+
// Babel supports json5 syntax, but json-source-map does not.
|
|
419
|
+
}
|
|
414
420
|
}
|
|
415
421
|
}
|
|
416
422
|
|