babel / babel/babel-loader

if set useBuiltIns: 'usage',then error is come

Open
#927 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
456
Avg merge
9h 19m
Merged PRs (30d)
2

Description

**Webpack Version:**
4.9.1

**Babel Core Version**:
7.16.7

**Babel Loader Version**:
8.2.3

**Please tell us about your environment:**
Windows 10

**Current behavior:**
if set useBuiltIns: 'usage',then error is come:
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
chrome: '60',
firefox: '60',
ie: '9',
safari: '10',
edge: '17'
},
useBuiltIns: 'usage',
corejs:3,
},
]
],
plugins:[
'@babel/plugin-transform-runtime',
]
}
}
},

**Expected/desired behavior:**
E:\webpack\src\js\test.js
1:1 error 'core-js' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
1:8 error Unexpected use of file extension "js" for "core-js/modules/es.object.to-string.js" import/extensions
2:1 error 'core-js' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
2:8 error Unexpected use of file extension "js" for "core-js/modules/es.promise.js" import/extensions
3:1 error 'core-js' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies
3:8 error Unexpected use of file extension "js" for "core-js/modules/web.timers.js" import/extensions
13:5 warning Unexpected console statement no-console
17:1 warning Unexpected console statement no-console

✖ 8 problems (6 errors, 2 warnings)

my package.json is:
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.16.8",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.16.8",
"babel-loader": "^8.2.3",
"core-js": "^3.20.3",
"css-loader": "^6.5.1",
"css-minimizer-webpack-plugin": "^3.3.1",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.25.4",
"file-loader": "^6.2.0",
"html-loader": "^3.1.0",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.4.7",
"postcss-loader": "^6.2.1",
"postcss-preset-env": "^7.2.3",
"style-loader": "^3.3.1",
"url-loader": "^4.1.1",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.7.3"
}

Contributor guide

Open the contributing guide

Research direction

Start with the package.json dependencies and the webpack rule shown for src/js/test.js; reproduce the Babel loader run with useBuiltIns: 'usage' and corejs: 3. Compare the generated core-js imports with the reported ESLint errors. No repository test or implementation file is named, so the issue is complete only when the intended build and lint behavior is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.