Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[babel-preset-react-app]: missing breaking change in 2.0 #5802

Closed
Stupidism opened this issue Nov 14, 2018 · 4 comments
Closed

[babel-preset-react-app]: missing breaking change in 2.0 #5802

Stupidism opened this issue Nov 14, 2018 · 4 comments
Labels

Comments

@Stupidism
Copy link

Stupidism commented Nov 14, 2018

Is this a bug report?

Yes

I was using an .babelrc with preset babel-preset-react-app to build my components inside a CRA project into commonJS modules. It turned out to be broken after upgraded to 2.0.

{
  "presets": ["react-app"],
  "plugins": [
    ["import", { "libraryName": "antd", "style": true }, "antd"],
    ["import", { "libraryName": "lodash", "libraryDirectory": "", "camel2DashComponentName": false }, "lodash"],
    ["import", { "libraryName": "recompose", "libraryDirectory": "", "camel2DashComponentName": false }, "recompose"],
    "@babel/plugin-transform-modules-commonjs"
  ]
}

I got these errors when building the other project that depends on the module.


Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/getPrototypeOf' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/inherits' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectSpread' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/toConsumableArray' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/toConsumableArray' in 'xxx-file'

Module not found: Error: Can't resolve '/Users/yyy-username/Documents/zzz-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/toConsumableArray' in 'xxx-file'

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

babel _interopRequireDefault using local path

I found this similar question. As babel team said they would never use absolute path in their code, so I came here.

Environment

Node 10.13.0
MacOS

Steps to Reproduce

  1. install dependencies
npm i -D babel-preset-react-app @babel/cli @babel/plugin-transform-modules-commonjs
  1. create a .babelrc with preset of react-app like this:
{
  "presets": ["react-app"],
  "plugins": [
    "@babel/plugin-transform-modules-commonjs"
  ]
}
  1. create an index.js with import and export default like this:
import a from './src/index';

export default a;
  1. run babel-cli

NODE_ENV=production ./node_modules/.bin/babel index.js --config-file ./.babelrc

Expected Behavior

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _index = _interopRequireDefault(require("./src/index"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _default = _index.default;
exports.default = _default;

Actually this comes out after I delete preset-react-app in babelrc file.

Actual Behavior


"use strict";
var _interopRequireDefault = require("/Users/xxx-username/Documents/yyy-project/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _index = _interopRequireDefault(require("./src/index"));

var _default = _index.default;
exports.default = _default;

Reproducible Demo

I created a reproducible demo

Just run npm test after npm install, you will see the absolute path.

@bugzpodder
Copy link

Does #5443 (comment) help?

@Stupidism
Copy link
Author

Does #5443 (comment) help?

Yes, it's a duplication. And the solution works for me if I add @babel/runtime into dependency of the library.

But it's still different than before.

Do you consider adding this as a breaking change?

For the preset-react-app config, it's not in the documentation, either.

@Timer
Copy link
Contributor

Timer commented Nov 15, 2018

It was released behind a major version of babel-preset-react-app. We don't track a changelog for that explicitly.

@stale
Copy link

stale bot commented Dec 15, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 15, 2018
@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants