How to use @babel/parser

Comprehensive @babel/parser code examples:

How to use @babel/parser.parseExpression:

68
69
70
71
72
73
74
75
76
77
78
79
        }
      }, global.CASE_TEST_START)
    }`
  }


  return parser.parseExpression(fn).body
}


module.exports = function (source) {
  const query = loaderUtils.parseQuery(this.resourceQuery || '?')

How to use @babel/parser.parse:

86
87
88
89
90
91
92
93
94

const fileCasePath = this.resourcePath
  .replace(/([\\/])(src)([\\/])/, (...args) => args[1] + 'test' + args[3])
  .replace(/\.\w{2,5}$/, '.js')

const astBase = parser.parse(script.content, {
  sourceType: 'module',
  plugins: ['jsx', 'dynamicImport'] // xvm中可以编译jsx语法;增加动态引入js的语法。这里注意。
})