|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | const babel = require("./babel-core.cjs");
|
|---|
| 4 | const convert = require("../convert/index.cjs");
|
|---|
| 5 | const astInfo = require("./ast-info.cjs");
|
|---|
| 6 | const extractParserOptionsPlugin = require("./extract-parser-options-plugin.cjs");
|
|---|
| 7 | const {
|
|---|
| 8 | getVisitorKeys,
|
|---|
| 9 | getTokLabels
|
|---|
| 10 | } = astInfo;
|
|---|
| 11 | const ref = {};
|
|---|
| 12 | let extractParserOptionsConfigItem;
|
|---|
| 13 | const MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;
|
|---|
| 14 | module.exports = function maybeParseSync(code, options) {
|
|---|
| 15 | if (!extractParserOptionsConfigItem) {
|
|---|
| 16 | extractParserOptionsConfigItem = babel.createConfigItemSync([extractParserOptionsPlugin, ref], {
|
|---|
| 17 | dirname: __dirname,
|
|---|
| 18 | type: "plugin"
|
|---|
| 19 | });
|
|---|
| 20 | }
|
|---|
| 21 | const {
|
|---|
| 22 | plugins
|
|---|
| 23 | } = options;
|
|---|
| 24 | options.plugins = plugins.concat(extractParserOptionsConfigItem);
|
|---|
| 25 | let ast;
|
|---|
| 26 | try {
|
|---|
| 27 | return {
|
|---|
| 28 | parserOptions: babel.parseSync(code, options),
|
|---|
| 29 | ast: null
|
|---|
| 30 | };
|
|---|
| 31 | } catch (err) {
|
|---|
| 32 | if (!MULTIPLE_OVERRIDES.test(err.message)) {
|
|---|
| 33 | throw err;
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 | options.plugins = plugins;
|
|---|
| 37 | try {
|
|---|
| 38 | ast = babel.parseSync(code, options);
|
|---|
| 39 | } catch (err) {
|
|---|
| 40 | throw convert.convertError(err);
|
|---|
| 41 | }
|
|---|
| 42 | return {
|
|---|
| 43 | ast: convert.convertFile(ast, code, getTokLabels(), getVisitorKeys()),
|
|---|
| 44 | parserOptions: null
|
|---|
| 45 | };
|
|---|
| 46 | };
|
|---|
| 47 |
|
|---|
| 48 | //# sourceMappingURL=maybeParseSync.cjs.map
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.