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

i use a few of new features that do not support, but it installed all polyfill. #6596

Closed
babel-bot opened this issue Oct 18, 2017 · 8 comments
Labels
imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env

Comments

@babel-bot
Copy link
Collaborator

Issue originally reported by @ouzhou in babel/babel-preset-env#450

for example, i only use Array.of() when i set "useBuiltIns": true, "targets": { "ie": 9 }, , but i get all polyfills which IE9 not support.

my babel-preset-env version is @1.6.1

and i tried using @next and set "useBuiltIns": "entry", but it warned Cannot read property 'loose' of undefined

@babel-bot
Copy link
Collaborator Author

Comment originally made by @existentialism

@ouzhou with version 1.6.1, it will load all polyfills needed for your target environment(s), which is an improvement from babel-polyfill which loads all polyfills regardless.

With version 2.x, useBuiltIns: entry matches this behavior, while useBuiltIns: usage will only add polyfills based on your code.

As for the loose option, can you provide your Babel config?

@babel-bot
Copy link
Collaborator Author

Comment originally made by @weizongqi1990

I have the same problem.
It my Babel config

{
  "plugins": [
      "lodash",
      "transform-runtime",
      "transform-proto-to-assign",
      "transform-decorators-legacy",
      "transform-decorators",
      "transform-class-properties"
  ],
  "presets": [["env",  {
      "loose": true,
      "module": false,
      "useBuiltIns": "entry",
      "targets": {
        "browsers": ["last 2 versions", "safari >= 7", "ie 9"]
      }
  }], "react", "stage-3", "flow"]
}

@babel-bot
Copy link
Collaborator Author

Comment originally made by @nicolo-ribaudo

@weizongqi1990 Can you also provide your package.json?

As a side note, I transform-decorators and transform-decorators-legacy are incompatible.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @weizongqi1990

@nicolo-ribaudo
Thanks.

{
    "name": "front-end",
    "version": "0.0.1",
    "description": "front-end",
    "main": "index.js",
    "author": "weizongqi1990",
    "license": "MIT",
    "config": {
        "webpack": "node_modules/.bin/webpack",
        "dllConfig": "./bulid/webpack/webpack.dll.config.js",
        "passportConfig": "./bulid/webpack/webpack.passport.config.js",
        "wwwConfig": "./bulid/webpack/webpack.www.config.js"
    },
    "scripts": {
        "predev:watch": "NODE_ENV=dev:local concurrently \"$npm_package_config_webpack --config $npm_package_config_dllConfig\"",
        "dev:watch": "NODE_ENV=dev:local concurrently \"node_modules/.bin/webpack-dev-server --config ./bulid/webpack/index.js\"",
        "build": "NODE_ENV=production concurrently \"$npm_package_config_webpack --config $npm_package_config_passportConfig\" \"$npm_package_config_webpack --config $npm_package_config_wwwConfig\"",
        "build:as": "BUILD_TYPE=as NODE_ENV=production concurrently \"$npm_package_config_webpack --config $npm_package_config_passportConfig\" \"$npm_package_config_webpack --config $npm_package_config_wwwConfig\"",
        "buildwww": "NODE_ENV=production concurrently \"$npm_package_config_webpack --config $npm_package_config_wwwConfig\"",
        "buildwww:as": "BUILD_TYPE=as NODE_ENV=production concurrently \"$npm_package_config_webpack --config $npm_package_config_wwwConfig\"",
        "test": "flow && jest",
        "flow": "flow --watch"
    },
    "devDependencies": {
        "add-asset-html-webpack-plugin": "^2.1.2",
        "autoprefixer": "^7.1.4",
        "babel-core": "^6.26.0",
        "babel-eslint": "^7.2.3",
        "babel-jest": "^20.0.3",
        "babel-loader": "^7.1.2",
        "babel-plugin-lodash": "^3.2.11",
        "babel-plugin-module-resolver": "^2.7.1",
        "babel-plugin-transform-class-properties": "^6.24.1",
        "babel-plugin-transform-decorators": "^6.24.1",
        "babel-plugin-transform-decorators-legacy": "^1.3.4",
        "babel-plugin-transform-es2015-classes": "^6.24.1",
        "babel-plugin-transform-runtime": "^6.23.0",
        "babel-preset-env": "^1.6.1",
        "babel-preset-react": "^6.24.1",
        "babel-preset-stage-3": "^6.24.1",
        "bundle-loader": "^0.5.5",
        "concurrently": "^3.5.0",
        "css-loader": "^0.28.4",
        "enzyme": "^2.9.1",
        "eslint": "^3.19.0",
        "eslint-config-airbnb": "^15.1.0",
        "eslint-config-airbnb-base": "^11.3.1",
        "eslint-friendly-formatter": "^3.0.0",
        "eslint-import-resolver-babel-module": "^3.0.0",
        "eslint-import-resolver-webpack": "^0.8.3",
        "eslint-loader": "^1.8.0",
        "eslint-plugin-flowtype": "^2.34.0",
        "eslint-plugin-import": "2.7.0",
        "eslint-plugin-jsx-a11y": "5.1.1",
        "eslint-plugin-react": "^7.1.0",
        "extract-text-webpack-plugin": "^3.0.0",
        "file-loader": "^1.1.5",
        "flow-bin": "0.52.0",
        "happypack": "^4.0.0-beta.5",
        "html-loader": "^0.5.1",
        "html-webpack-plugin": "^2.30.1",
        "inline-manifest-webpack-plugin": "^3.0.1",
        "jest": "^20.0.4",
        "less": "^2.7.2",
        "less-loader": "^4.0.5",
        "lodash-webpack-plugin": "^0.11.4",
        "postcss-loader": "^2.0.6",
        "raw-loader": "^0.5.1",
        "react-test-renderer": "^16.0.0",
        "source-map-loader": "^0.2.1",
        "style-loader": "^0.18.2",
        "url-loader": "^0.6.2",
        "webpack": "^3.8.1",
        "webpack-bundle-analyzer": "^2.9.0",
        "webpack-chunk-hash": "^0.5.0",
        "webpack-dev-server": "^2.9.2",
        "webpack-merge": "^4.1.0",
        "webpack-uglify-parallel": "^0.1.4"
    },
    "dependencies": {
        "axios": "^0.16.2",
        "babel-polyfill": "^6.26.0",
        "babel-standalone": "^6.26.0",
        "console-polyfill": "^0.3.0",
        "core-js": "^2.5.0",
        "date-fns": "^1.28.5",
        "es6-promise": "^4.1.1",
        "history": "^4.7.2",
        "localforage": "^1.5.2",
        "lodash": "^4.17.4",
        "marked": "^0.3.6",
        "mobx": "^3.3.1",
        "mobx-react": "^4.3.3",
        "nprogress": "^0.2.0",
        "polished": "^1.8.1",
        "prismjs": "^1.6.0",
        "prop-types": "^15.5.10",
        "react": "^16.0.0",
        "react-addons-perf": "^15.4.2",
        "react-dom": "^16.0.0",
        "react-hot-loader": "next",
        "react-motion": "^0.5.2",
        "react-router": "^4.2.0",
        "react-router-dom": "^4.2.2",
        "react-router-transition": "^1.1.1",
        "react-tiny-virtual-list": "^2.1.2",
        "shallowequal": "^1.0.2",
        "styled-components": "^2.2.1",
        "webpack-dev-middleware": "^1.12.0",
        "webpack-sources": "^1.0.1",
        "why-did-you-update": "^0.0.8"
    },
    "jest": {
        "globals": {
            "widow": true
        },
        "collectCoverage": true,
        "modulePaths": [
            "<rootDir>/src/"
        ],
        "moduleNameMapper": {
            "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/flow/__mocks__/fileMock.js",
            "\\.(css)$": "<rootDir>/flow/__mocks__/styleMock.js"
        },
        "setupFiles": [
            "<rootDir>/test/main.js"
        ]
    }
}

@babel-bot
Copy link
Collaborator Author

Comment originally made by @nicolo-ribaudo

useBuiltIns: entry/usage is only supported in version 2, you are using ^1.6.1.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @weizongqi1990

But,i use ^2,i got

/Users/nico/56hello/fronted/master/front-end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328
[0]         throw e;
[0]         ^
[0]
[0] TypeError: Cannot read property 'loose' of undefined (While processing preset: "/Users/nico/56hello/fronted/master/front-end/node_modules/babel-preset-env/lib/index.js")

@babel-bot
Copy link
Collaborator Author

Comment originally made by @existentialism

@weizongqi1990 babel-preset-env 2.x (really, you should use the latest 7.0-beta.x) requires matching 7.0-beta.x Babel dependencies.

Sorry for the confusion, we're working on making this clearer asap.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @weizongqi1990

@existentialism
Thank you for your reply!

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 10, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
imported outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env
Projects
None yet
Development

No branches or pull requests

2 participants