@parcel/utils 2.0.0-nightly.954 → 2.0.0-nightly.959
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 +39 -1
- package/package.json +7 -7
- package/src/config.js +34 -1
package/lib/config.js
CHANGED
|
@@ -7,6 +7,16 @@ exports.resolveConfig = resolveConfig;
|
|
|
7
7
|
exports.resolveConfigSync = resolveConfigSync;
|
|
8
8
|
exports.loadConfig = loadConfig;
|
|
9
9
|
|
|
10
|
+
function _diagnostic() {
|
|
11
|
+
const data = _interopRequireDefault(require("@parcel/diagnostic"));
|
|
12
|
+
|
|
13
|
+
_diagnostic = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
function _path() {
|
|
11
21
|
const data = _interopRequireDefault(require("path"));
|
|
12
22
|
|
|
@@ -120,7 +130,35 @@ async function loadConfig(fs, filepath, filenames, projectRoot, opts) {
|
|
|
120
130
|
var _opts$parser;
|
|
121
131
|
|
|
122
132
|
let parse = (_opts$parser = opts === null || opts === void 0 ? void 0 : opts.parser) !== null && _opts$parser !== void 0 ? _opts$parser : getParser(extname);
|
|
123
|
-
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
config = parse(configContent);
|
|
136
|
+
} catch (e) {
|
|
137
|
+
if (extname !== '' && extname !== 'json') {
|
|
138
|
+
throw e;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let pos = {
|
|
142
|
+
line: e.lineNumber,
|
|
143
|
+
column: e.columnNumber
|
|
144
|
+
};
|
|
145
|
+
throw new (_diagnostic().default)({
|
|
146
|
+
diagnostic: {
|
|
147
|
+
message: `Failed to parse ${_path().default.basename(configFile)}`,
|
|
148
|
+
origin: '@parcel/utils',
|
|
149
|
+
codeFrames: [{
|
|
150
|
+
language: 'json5',
|
|
151
|
+
filePath: configFile,
|
|
152
|
+
code: configContent,
|
|
153
|
+
codeHighlights: [{
|
|
154
|
+
start: pos,
|
|
155
|
+
end: pos,
|
|
156
|
+
message: e.message
|
|
157
|
+
}]
|
|
158
|
+
}]
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
124
162
|
}
|
|
125
163
|
|
|
126
164
|
let output = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/utils",
|
|
3
|
-
"version": "2.0.0-nightly.
|
|
3
|
+
"version": "2.0.0-nightly.959+13649c36",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@iarna/toml": "^2.2.0",
|
|
24
|
-
"@parcel/codeframe": "2.0.0-nightly.
|
|
25
|
-
"@parcel/diagnostic": "2.0.0-nightly.
|
|
26
|
-
"@parcel/hash": "2.0.2-nightly.
|
|
27
|
-
"@parcel/logger": "2.0.0-nightly.
|
|
28
|
-
"@parcel/markdown-ansi": "2.0.0-nightly.
|
|
24
|
+
"@parcel/codeframe": "2.0.0-nightly.959+13649c36",
|
|
25
|
+
"@parcel/diagnostic": "2.0.0-nightly.959+13649c36",
|
|
26
|
+
"@parcel/hash": "2.0.2-nightly.2581+13649c36",
|
|
27
|
+
"@parcel/logger": "2.0.0-nightly.959+13649c36",
|
|
28
|
+
"@parcel/markdown-ansi": "2.0.0-nightly.959+13649c36",
|
|
29
29
|
"@parcel/source-map": "^2.0.0",
|
|
30
30
|
"ansi-html-community": "0.0.8",
|
|
31
31
|
"chalk": "^4.1.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"./src/http-server.js": false,
|
|
52
52
|
"./src/openInBrowser.js": false
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "13649c365d36b40e548e34e2e278bdb4cd1de48a"
|
|
55
55
|
}
|
package/src/config.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type {ConfigResult, File, FilePath} from '@parcel/types';
|
|
4
4
|
import type {FileSystem} from '@parcel/fs';
|
|
5
|
+
import ThrowableDiagnostic from '@parcel/diagnostic';
|
|
5
6
|
import path from 'path';
|
|
6
7
|
import clone from 'clone';
|
|
7
8
|
import {parse as json5} from 'json5';
|
|
@@ -88,7 +89,39 @@ export async function loadConfig(
|
|
|
88
89
|
config = configContent;
|
|
89
90
|
} else {
|
|
90
91
|
let parse = opts?.parser ?? getParser(extname);
|
|
91
|
-
|
|
92
|
+
try {
|
|
93
|
+
config = parse(configContent);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
if (extname !== '' && extname !== 'json') {
|
|
96
|
+
throw e;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let pos = {
|
|
100
|
+
line: e.lineNumber,
|
|
101
|
+
column: e.columnNumber,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
throw new ThrowableDiagnostic({
|
|
105
|
+
diagnostic: {
|
|
106
|
+
message: `Failed to parse ${path.basename(configFile)}`,
|
|
107
|
+
origin: '@parcel/utils',
|
|
108
|
+
codeFrames: [
|
|
109
|
+
{
|
|
110
|
+
language: 'json5',
|
|
111
|
+
filePath: configFile,
|
|
112
|
+
code: configContent,
|
|
113
|
+
codeHighlights: [
|
|
114
|
+
{
|
|
115
|
+
start: pos,
|
|
116
|
+
end: pos,
|
|
117
|
+
message: e.message,
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|
|
92
125
|
}
|
|
93
126
|
|
|
94
127
|
let output = {
|