Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

PreflightCheck Error #267

Closed
zsky opened this issue Oct 19, 2018 · 8 comments
Closed

PreflightCheck Error #267

zsky opened this issue Oct 19, 2018 · 8 comments

Comments

@zsky
Copy link

zsky commented Oct 19, 2018

The code below emitted a error, because transpiled code with babel had no matching condition

if (check.match(/\/helpers\/(esm\/)?inherits/)) helpers = RUNTIME;
else if (~check.indexOf('function _inherits')) helpers = INLINE;
else if (~check.indexOf('babelHelpers')) helpers = EXTERNAL;
else {
	ctx.error(UNEXPECTED_ERROR);
}

babel version: 7.0.0-beta.47
the output code was

import _classCallCheck from "/path/to/node_modules/@babel/runtime/helpers/builtin/es6/classCallCheck";
import _inherits from "/path/to/node_modules/@babel/runtime/helpers/builtin/es6/inherits";
import _possibleConstructorReturn from "/path/to/node_modules/@babel/runtime/helpers/builtin/es6/possibleConstructorReturn";
import _getPrototypeOf from "/path/to/node_modules/@babel/runtime/helpers/builtin/es6/getPrototypeOf";

var Foo =
/*#__PURE__*/
function (_Bar) {
  function Foo() {
    _classCallCheck(this, Foo);

    return _possibleConstructorReturn(this, _getPrototypeOf(Foo).apply(this, arguments));
  }

  _inherits(Foo, _Bar);

  return Foo;
}(Bar);

;
export default Foo;

I tried babel 7.1.2, also got error

@Andarist
Copy link
Member

Andarist commented Oct 19, 2018

Could u paste in your rollup & babel configs? I think you are relaying on babel's removed option

@zsky
Copy link
Author

zsky commented Oct 19, 2018

I think the option useESModules of @babel/plugin-transform-runtime caused the problem.

I used https://github.com/vuejs/vue-cli to create the project, my bable config:

module.exports = {
  presets: ['@vue/app']
};

my rollup config:

import globby from 'globby';
import vue from 'rollup-plugin-vue';
import css from 'rollup-plugin-css-only';
import babel from 'rollup-plugin-babel';

const files = globby.sync(['packages/**']);

export default files.map((file) => {
  return {
    input: file,
    output: {
      file: file.replace('packages', 'dist').replace('.vue', '.js'),
      format: 'cjs'
    },
    plugins: [vue({ css: false }), css(), babel()],
    external: (id) => {
      return id.startsWith('.') || id === 'vue';
    }
  };
});

@Andarist
Copy link
Member

Could you file an issue (or check if there is any already about it) in vue-cli repo? They have a little bit outdated dependencies - https://github.com/vuejs/vue-cli/blob/528c46507a21b76f12bc416d98f9b04c0076cb50/packages/%40vue/babel-preset-app/package.json#L24-L30

For the time being it seems that you should downgrade your rollup-plugin-babel to 4.0.0-beta.7

@zsky
Copy link
Author

zsky commented Oct 21, 2018

They had upgraded recently: vuejs/vue-cli#2642
But even if I upgraded the babel, I still have this error. #268 said preflightCheck will be removed,how long will it takes?

@Andarist
Copy link
Member

Could u prepare a repro case? What kind of an error do you see? What is the output code?

@zsky
Copy link
Author

zsky commented Oct 23, 2018

I made a minimal repo to reproduce:

git clone [email protected]:zsky/rollup-plugin-babel-issue267.git
cd rollup-plugin-babel-issue267
npm i
npm run build

Then outputed a error:

(babel plugin) Error: An unexpected situation arose.

I logged the code, the _inherits:

import _inherits from "@babel/runtime/helpers/es6/inherits";

@Andarist
Copy link
Member

The installed @vue/[email protected] has still outdated babel dependencies.

@zsky zsky closed this as completed Oct 24, 2018
@zsky
Copy link
Author

zsky commented Oct 24, 2018

I changed the babel config, set useESModules false, solved my problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants