// https://github.com/babel/babel/blob/v7.23.6/packages/babel-plugin-syntax-typescript/src/index.ts#L59 manipulateOptions(opts, parserOpts) { if (!process.env.BABEL_8_BREAKING) { const {plugins} = parserOpts; // If the Flow syntax plugin already ran, remove it since Typescript // takes priority. removePlugin(plugins, "flow");
// If the JSX syntax plugin already ran, remove it because JSX handling // in TS depends on the extensions, and is purely dependent on 'isTSX'. removePlugin(plugins, "jsx");
// These are now enabled by default in @babel/parser, but we push // them for compat with older versions. plugins.push("objectRestSpread", "classProperties");
//https://github.com/babel/babel/blob/v7.23.6/packages/babel-plugin-syntax-jsx/src/index.ts manipulateOptions(opts, parserOpts) { if (!process.env.BABEL_8_BREAKING) { // If the Typescript plugin already ran, it will have decided whether // or not this is a TSX file. if ( parserOpts.plugins.some( p => (Array.isArray(p) ? p[0] : p) === "typescript", ) // 这里错了,不能单纯的说我用了@babel/plugin-transform-typescript,就return掉,应该判断是否开启了jsx plugin ) { return; } }