Skip to content

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

Description

@zzswang

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions