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

[Help] Failed to minify the code from the pkg owned by myself #5084

Closed
zzswang opened this issue Sep 25, 2018 · 1 comment
Closed

[Help] Failed to minify the code from the pkg owned by myself #5084

zzswang opened this issue Sep 25, 2018 · 1 comment

Comments

@zzswang
Copy link

zzswang commented Sep 25, 2018

I have a child repo called fetch, which wrap the origin fetch. This project is designed to be used both in node (with node-fetch) and browser.

but it is running into error, even we've precompiled it.

the .babelrc for repo fetch

{
  "presets": [
    [
      "env",
      {
        "targets": {
          "node": "current"
        }
      }
    ],
    "stage-0"
  ],
  "plugins": [
    [
      "transform-builtin-extend",
      {
        "globals": ["Error", "Array"]
      }
    ]
  ]
}

Here we use targets node, since it is required for async/await transforming.

related babel dependencies.

    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^7.2.3",
    "babel-jest": "^23.2.0",
    "babel-plugin-transform-builtin-extend": "^1.1.2",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-0": "^6.24.1"

compile to

https://gist.github.com/zzswang/9763fe903b364d2e4f11b1a4618aa669

when used it in create-react-app

It is running into the minify error.
There must be something wrong with my .babelrc.

If we change targets from:

[
      "env",
      {
        "targets": {
          "node": "current"
        }
      }
]

to

    [
      "env",
      {
        "modules": false
      }
    ]

minify will be ok, but start dev will failed due to:

ReferenceError: regeneratorRuntime is not defined

Could anyone help?
Thanks.

@Timer
Copy link
Contributor

Timer commented Sep 26, 2018

Hi! This is a general babel configuration question that we can't help troubleshoot, sorry!

My suggestion though, use axios instead of writing your own library.

Thanks!

@Timer Timer closed this as completed Sep 26, 2018
@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
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