[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = generateMissingPluginMessage;
|
---|
| 7 | const pluginNameMap = {
|
---|
| 8 | asyncDoExpressions: {
|
---|
| 9 | syntax: {
|
---|
| 10 | name: "@babel/plugin-syntax-async-do-expressions",
|
---|
| 11 | url: "https://git.io/JYer8"
|
---|
| 12 | }
|
---|
| 13 | },
|
---|
| 14 | classProperties: {
|
---|
| 15 | syntax: {
|
---|
| 16 | name: "@babel/plugin-syntax-class-properties",
|
---|
| 17 | url: "https://git.io/vb4yQ"
|
---|
| 18 | },
|
---|
| 19 | transform: {
|
---|
| 20 | name: "@babel/plugin-proposal-class-properties",
|
---|
| 21 | url: "https://git.io/vb4SL"
|
---|
| 22 | }
|
---|
| 23 | },
|
---|
| 24 | classPrivateProperties: {
|
---|
| 25 | syntax: {
|
---|
| 26 | name: "@babel/plugin-syntax-class-properties",
|
---|
| 27 | url: "https://git.io/vb4yQ"
|
---|
| 28 | },
|
---|
| 29 | transform: {
|
---|
| 30 | name: "@babel/plugin-proposal-class-properties",
|
---|
| 31 | url: "https://git.io/vb4SL"
|
---|
| 32 | }
|
---|
| 33 | },
|
---|
| 34 | classPrivateMethods: {
|
---|
| 35 | syntax: {
|
---|
| 36 | name: "@babel/plugin-syntax-class-properties",
|
---|
| 37 | url: "https://git.io/vb4yQ"
|
---|
| 38 | },
|
---|
| 39 | transform: {
|
---|
| 40 | name: "@babel/plugin-proposal-private-methods",
|
---|
| 41 | url: "https://git.io/JvpRG"
|
---|
| 42 | }
|
---|
| 43 | },
|
---|
| 44 | classStaticBlock: {
|
---|
| 45 | syntax: {
|
---|
| 46 | name: "@babel/plugin-syntax-class-static-block",
|
---|
| 47 | url: "https://git.io/JTLB6"
|
---|
| 48 | },
|
---|
| 49 | transform: {
|
---|
| 50 | name: "@babel/plugin-proposal-class-static-block",
|
---|
| 51 | url: "https://git.io/JTLBP"
|
---|
| 52 | }
|
---|
| 53 | },
|
---|
| 54 | decimal: {
|
---|
| 55 | syntax: {
|
---|
| 56 | name: "@babel/plugin-syntax-decimal",
|
---|
| 57 | url: "https://git.io/JfKOH"
|
---|
| 58 | }
|
---|
| 59 | },
|
---|
| 60 | decorators: {
|
---|
| 61 | syntax: {
|
---|
| 62 | name: "@babel/plugin-syntax-decorators",
|
---|
| 63 | url: "https://git.io/vb4y9"
|
---|
| 64 | },
|
---|
| 65 | transform: {
|
---|
| 66 | name: "@babel/plugin-proposal-decorators",
|
---|
| 67 | url: "https://git.io/vb4ST"
|
---|
| 68 | }
|
---|
| 69 | },
|
---|
| 70 | doExpressions: {
|
---|
| 71 | syntax: {
|
---|
| 72 | name: "@babel/plugin-syntax-do-expressions",
|
---|
| 73 | url: "https://git.io/vb4yh"
|
---|
| 74 | },
|
---|
| 75 | transform: {
|
---|
| 76 | name: "@babel/plugin-proposal-do-expressions",
|
---|
| 77 | url: "https://git.io/vb4S3"
|
---|
| 78 | }
|
---|
| 79 | },
|
---|
| 80 | dynamicImport: {
|
---|
| 81 | syntax: {
|
---|
| 82 | name: "@babel/plugin-syntax-dynamic-import",
|
---|
| 83 | url: "https://git.io/vb4Sv"
|
---|
| 84 | }
|
---|
| 85 | },
|
---|
| 86 | exportDefaultFrom: {
|
---|
| 87 | syntax: {
|
---|
| 88 | name: "@babel/plugin-syntax-export-default-from",
|
---|
| 89 | url: "https://git.io/vb4SO"
|
---|
| 90 | },
|
---|
| 91 | transform: {
|
---|
| 92 | name: "@babel/plugin-proposal-export-default-from",
|
---|
| 93 | url: "https://git.io/vb4yH"
|
---|
| 94 | }
|
---|
| 95 | },
|
---|
| 96 | exportNamespaceFrom: {
|
---|
| 97 | syntax: {
|
---|
| 98 | name: "@babel/plugin-syntax-export-namespace-from",
|
---|
| 99 | url: "https://git.io/vb4Sf"
|
---|
| 100 | },
|
---|
| 101 | transform: {
|
---|
| 102 | name: "@babel/plugin-proposal-export-namespace-from",
|
---|
| 103 | url: "https://git.io/vb4SG"
|
---|
| 104 | }
|
---|
| 105 | },
|
---|
| 106 | flow: {
|
---|
| 107 | syntax: {
|
---|
| 108 | name: "@babel/plugin-syntax-flow",
|
---|
| 109 | url: "https://git.io/vb4yb"
|
---|
| 110 | },
|
---|
| 111 | transform: {
|
---|
| 112 | name: "@babel/preset-flow",
|
---|
| 113 | url: "https://git.io/JfeDn"
|
---|
| 114 | }
|
---|
| 115 | },
|
---|
| 116 | functionBind: {
|
---|
| 117 | syntax: {
|
---|
| 118 | name: "@babel/plugin-syntax-function-bind",
|
---|
| 119 | url: "https://git.io/vb4y7"
|
---|
| 120 | },
|
---|
| 121 | transform: {
|
---|
| 122 | name: "@babel/plugin-proposal-function-bind",
|
---|
| 123 | url: "https://git.io/vb4St"
|
---|
| 124 | }
|
---|
| 125 | },
|
---|
| 126 | functionSent: {
|
---|
| 127 | syntax: {
|
---|
| 128 | name: "@babel/plugin-syntax-function-sent",
|
---|
| 129 | url: "https://git.io/vb4yN"
|
---|
| 130 | },
|
---|
| 131 | transform: {
|
---|
| 132 | name: "@babel/plugin-proposal-function-sent",
|
---|
| 133 | url: "https://git.io/vb4SZ"
|
---|
| 134 | }
|
---|
| 135 | },
|
---|
| 136 | importMeta: {
|
---|
| 137 | syntax: {
|
---|
| 138 | name: "@babel/plugin-syntax-import-meta",
|
---|
| 139 | url: "https://git.io/vbKK6"
|
---|
| 140 | }
|
---|
| 141 | },
|
---|
| 142 | jsx: {
|
---|
| 143 | syntax: {
|
---|
| 144 | name: "@babel/plugin-syntax-jsx",
|
---|
| 145 | url: "https://git.io/vb4yA"
|
---|
| 146 | },
|
---|
| 147 | transform: {
|
---|
| 148 | name: "@babel/preset-react",
|
---|
| 149 | url: "https://git.io/JfeDR"
|
---|
| 150 | }
|
---|
| 151 | },
|
---|
| 152 | importAssertions: {
|
---|
| 153 | syntax: {
|
---|
| 154 | name: "@babel/plugin-syntax-import-assertions",
|
---|
| 155 | url: "https://git.io/JUbkv"
|
---|
| 156 | }
|
---|
| 157 | },
|
---|
| 158 | moduleStringNames: {
|
---|
| 159 | syntax: {
|
---|
| 160 | name: "@babel/plugin-syntax-module-string-names",
|
---|
| 161 | url: "https://git.io/JTL8G"
|
---|
| 162 | }
|
---|
| 163 | },
|
---|
| 164 | numericSeparator: {
|
---|
| 165 | syntax: {
|
---|
| 166 | name: "@babel/plugin-syntax-numeric-separator",
|
---|
| 167 | url: "https://git.io/vb4Sq"
|
---|
| 168 | },
|
---|
| 169 | transform: {
|
---|
| 170 | name: "@babel/plugin-proposal-numeric-separator",
|
---|
| 171 | url: "https://git.io/vb4yS"
|
---|
| 172 | }
|
---|
| 173 | },
|
---|
| 174 | optionalChaining: {
|
---|
| 175 | syntax: {
|
---|
| 176 | name: "@babel/plugin-syntax-optional-chaining",
|
---|
| 177 | url: "https://git.io/vb4Sc"
|
---|
| 178 | },
|
---|
| 179 | transform: {
|
---|
| 180 | name: "@babel/plugin-proposal-optional-chaining",
|
---|
| 181 | url: "https://git.io/vb4Sk"
|
---|
| 182 | }
|
---|
| 183 | },
|
---|
| 184 | pipelineOperator: {
|
---|
| 185 | syntax: {
|
---|
| 186 | name: "@babel/plugin-syntax-pipeline-operator",
|
---|
| 187 | url: "https://git.io/vb4yj"
|
---|
| 188 | },
|
---|
| 189 | transform: {
|
---|
| 190 | name: "@babel/plugin-proposal-pipeline-operator",
|
---|
| 191 | url: "https://git.io/vb4SU"
|
---|
| 192 | }
|
---|
| 193 | },
|
---|
| 194 | privateIn: {
|
---|
| 195 | syntax: {
|
---|
| 196 | name: "@babel/plugin-syntax-private-property-in-object",
|
---|
| 197 | url: "https://git.io/JfK3q"
|
---|
| 198 | },
|
---|
| 199 | transform: {
|
---|
| 200 | name: "@babel/plugin-proposal-private-property-in-object",
|
---|
| 201 | url: "https://git.io/JfK3O"
|
---|
| 202 | }
|
---|
| 203 | },
|
---|
| 204 | recordAndTuple: {
|
---|
| 205 | syntax: {
|
---|
| 206 | name: "@babel/plugin-syntax-record-and-tuple",
|
---|
| 207 | url: "https://git.io/JvKp3"
|
---|
| 208 | }
|
---|
| 209 | },
|
---|
| 210 | throwExpressions: {
|
---|
| 211 | syntax: {
|
---|
| 212 | name: "@babel/plugin-syntax-throw-expressions",
|
---|
| 213 | url: "https://git.io/vb4SJ"
|
---|
| 214 | },
|
---|
| 215 | transform: {
|
---|
| 216 | name: "@babel/plugin-proposal-throw-expressions",
|
---|
| 217 | url: "https://git.io/vb4yF"
|
---|
| 218 | }
|
---|
| 219 | },
|
---|
| 220 | typescript: {
|
---|
| 221 | syntax: {
|
---|
| 222 | name: "@babel/plugin-syntax-typescript",
|
---|
| 223 | url: "https://git.io/vb4SC"
|
---|
| 224 | },
|
---|
| 225 | transform: {
|
---|
| 226 | name: "@babel/preset-typescript",
|
---|
| 227 | url: "https://git.io/JfeDz"
|
---|
| 228 | }
|
---|
| 229 | },
|
---|
| 230 | asyncGenerators: {
|
---|
| 231 | syntax: {
|
---|
| 232 | name: "@babel/plugin-syntax-async-generators",
|
---|
| 233 | url: "https://git.io/vb4SY"
|
---|
| 234 | },
|
---|
| 235 | transform: {
|
---|
| 236 | name: "@babel/plugin-proposal-async-generator-functions",
|
---|
| 237 | url: "https://git.io/vb4yp"
|
---|
| 238 | }
|
---|
| 239 | },
|
---|
| 240 | logicalAssignment: {
|
---|
| 241 | syntax: {
|
---|
| 242 | name: "@babel/plugin-syntax-logical-assignment-operators",
|
---|
| 243 | url: "https://git.io/vAlBp"
|
---|
| 244 | },
|
---|
| 245 | transform: {
|
---|
| 246 | name: "@babel/plugin-proposal-logical-assignment-operators",
|
---|
| 247 | url: "https://git.io/vAlRe"
|
---|
| 248 | }
|
---|
| 249 | },
|
---|
| 250 | nullishCoalescingOperator: {
|
---|
| 251 | syntax: {
|
---|
| 252 | name: "@babel/plugin-syntax-nullish-coalescing-operator",
|
---|
| 253 | url: "https://git.io/vb4yx"
|
---|
| 254 | },
|
---|
| 255 | transform: {
|
---|
| 256 | name: "@babel/plugin-proposal-nullish-coalescing-operator",
|
---|
| 257 | url: "https://git.io/vb4Se"
|
---|
| 258 | }
|
---|
| 259 | },
|
---|
| 260 | objectRestSpread: {
|
---|
| 261 | syntax: {
|
---|
| 262 | name: "@babel/plugin-syntax-object-rest-spread",
|
---|
| 263 | url: "https://git.io/vb4y5"
|
---|
| 264 | },
|
---|
| 265 | transform: {
|
---|
| 266 | name: "@babel/plugin-proposal-object-rest-spread",
|
---|
| 267 | url: "https://git.io/vb4Ss"
|
---|
| 268 | }
|
---|
| 269 | },
|
---|
| 270 | optionalCatchBinding: {
|
---|
| 271 | syntax: {
|
---|
| 272 | name: "@babel/plugin-syntax-optional-catch-binding",
|
---|
| 273 | url: "https://git.io/vb4Sn"
|
---|
| 274 | },
|
---|
| 275 | transform: {
|
---|
| 276 | name: "@babel/plugin-proposal-optional-catch-binding",
|
---|
| 277 | url: "https://git.io/vb4SI"
|
---|
| 278 | }
|
---|
| 279 | }
|
---|
| 280 | };
|
---|
| 281 | pluginNameMap.privateIn.syntax = pluginNameMap.privateIn.transform;
|
---|
| 282 |
|
---|
| 283 | const getNameURLCombination = ({
|
---|
| 284 | name,
|
---|
| 285 | url
|
---|
| 286 | }) => `${name} (${url})`;
|
---|
| 287 |
|
---|
| 288 | function generateMissingPluginMessage(missingPluginName, loc, codeFrame) {
|
---|
| 289 | let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame;
|
---|
| 290 | const pluginInfo = pluginNameMap[missingPluginName];
|
---|
| 291 |
|
---|
| 292 | if (pluginInfo) {
|
---|
| 293 | const {
|
---|
| 294 | syntax: syntaxPlugin,
|
---|
| 295 | transform: transformPlugin
|
---|
| 296 | } = pluginInfo;
|
---|
| 297 |
|
---|
| 298 | if (syntaxPlugin) {
|
---|
| 299 | const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
|
---|
| 300 |
|
---|
| 301 | if (transformPlugin) {
|
---|
| 302 | const transformPluginInfo = getNameURLCombination(transformPlugin);
|
---|
| 303 | const sectionType = transformPlugin.name.startsWith("@babel/plugin") ? "plugins" : "presets";
|
---|
| 304 | helpMessage += `\n\nAdd ${transformPluginInfo} to the '${sectionType}' section of your Babel config to enable transformation.
|
---|
| 305 | If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section to enable parsing.`;
|
---|
| 306 | } else {
|
---|
| 307 | helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`;
|
---|
| 308 | }
|
---|
| 309 | }
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | return helpMessage;
|
---|
| 313 | } |
---|