Skip to content

Commit

Permalink
Remove dependency on loader-utils and drop webpack 4 support (#942)
Browse files Browse the repository at this point in the history
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
  • Loading branch information
nied and JLHwung committed Oct 26, 2022
1 parent 12876a5 commit 9a2451f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -20,10 +20,10 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [14.x, 16.x]
webpack-version: [latest, '4']
node-version: [14, 16, 18]
webpack-version: ['5']
include:
- node-version: 18.x
- node-version: latest
webpack-version: latest
os: ubuntu-latest
coverage: true
Expand Down
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -11,12 +11,11 @@
},
"dependencies": {
"find-cache-dir": "^3.3.2",
"loader-utils": "^2.0.0",
"schema-utils": "^4.0.0"
},
"peerDependencies": {
"@babel/core": "^7.12.0",
"webpack": ">=2"
"webpack": ">=5"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
Expand Down
4 changes: 1 addition & 3 deletions src/index.js
Expand Up @@ -26,7 +26,6 @@ const injectCaller = require("./injectCaller");
const schema = require("./schema");

const { isAbsolute } = require("path");
const loaderUtils = require("loader-utils");
const validateOptions = require("schema-utils").validate;

function subscribe(subscriber, metadata, context) {
Expand Down Expand Up @@ -55,8 +54,7 @@ function makeLoader(callback) {
async function loader(source, inputSourceMap, overrides) {
const filename = this.resourcePath;

let loaderOptions = loaderUtils.getOptions(this);

let loaderOptions = this.getOptions();
validateOptions(schema, loaderOptions, {
name: "Babel loader",
});
Expand Down
6 changes: 5 additions & 1 deletion test/cache.test.js
Expand Up @@ -171,8 +171,12 @@ test.serial.cb(
rules: [
{
test: /\.jsx?/,
use: `${babelLoader}?cacheDirectory=true&presets[]=@babel/preset-env`,
loader: babelLoader,
exclude: /node_modules/,
options: {
cacheDirectory: true,
presets: ["@babel/preset-env"],
},
},
],
},
Expand Down
10 changes: 8 additions & 2 deletions test/options.test.js
Expand Up @@ -14,8 +14,11 @@ const globalConfig = {
rules: [
{
test: /\.jsx?/,
use: babelLoader,
loader: babelLoader,
exclude: /node_modules/,
options: {
presets: ["@babel/env"],
},
},
],
},
Expand All @@ -42,8 +45,11 @@ test.cb("should interpret options given to the loader", t => {
rules: [
{
test: /\.jsx?/,
use: babelLoader + "?presets[]=@babel/env",
loader: babelLoader,
exclude: /node_modules/,
options: {
presets: ["@babel/env"],
},
},
],
},
Expand Down
10 changes: 8 additions & 2 deletions test/sourcemaps.test.js
Expand Up @@ -44,8 +44,11 @@ test.cb("should output webpack's sourcemap", t => {
rules: [
{
test: /\.jsx?/,
use: babelLoader + "?presets[]=@babel/env",
loader: babelLoader,
exclude: /node_modules/,
options: {
presets: ["@babel/env"],
},
},
],
},
Expand Down Expand Up @@ -147,8 +150,11 @@ test.cb("should output webpack's devtoolModuleFilename option", t => {
rules: [
{
test: /\.jsx?/,
use: babelLoader + "?presets[]=@babel/env",
loader: babelLoader,
exclude: /node_modules/,
options: {
presets: ["@babel/env"],
},
},
],
},
Expand Down
28 changes: 1 addition & 27 deletions yarn.lock
Expand Up @@ -2232,7 +2232,6 @@ __metadata:
find-cache-dir: ^3.3.2
husky: ^4.3.0
lint-staged: ^10.5.1
loader-utils: ^2.0.0
nyc: ^15.1.0
pnp-webpack-plugin: ^1.6.4
prettier: ^2.1.2
Expand All @@ -2245,7 +2244,7 @@ __metadata:
webpack: ^5.34.0
peerDependencies:
"@babel/core": ^7.12.0
webpack: ">=2"
webpack: ">=5"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2334,13 +2333,6 @@ __metadata:
languageName: node
linkType: hard

"big.js@npm:^5.2.2":
version: 5.2.2
resolution: "big.js@npm:5.2.2"
checksum: b89b6e8419b097a8fb4ed2399a1931a68c612bce3cfd5ca8c214b2d017531191070f990598de2fc6f3f993d91c0f08aa82697717f6b3b8732c9731866d233c9e
languageName: node
linkType: hard

"binary-extensions@npm:^1.0.0":
version: 1.13.1
resolution: "binary-extensions@npm:1.13.1"
Expand Down Expand Up @@ -3308,13 +3300,6 @@ __metadata:
languageName: node
linkType: hard

"emojis-list@npm:^3.0.0":
version: 3.0.0
resolution: "emojis-list@npm:3.0.0"
checksum: ddaaa02542e1e9436c03970eeed445f4ed29a5337dfba0fe0c38dfdd2af5da2429c2a0821304e8a8d1cadf27fdd5b22ff793571fa803ae16852a6975c65e8e70
languageName: node
linkType: hard

"empower-core@npm:^1.2.0":
version: 1.2.0
resolution: "empower-core@npm:1.2.0"
Expand Down Expand Up @@ -5320,17 +5305,6 @@ fsevents@~2.1.2:
languageName: node
linkType: hard

"loader-utils@npm:^2.0.0":
version: 2.0.2
resolution: "loader-utils@npm:2.0.2"
dependencies:
big.js: ^5.2.2
emojis-list: ^3.0.0
json5: ^2.1.2
checksum: 9078d1ed47cadc57f4c6ddbdb2add324ee7da544cea41de3b7f1128e8108fcd41cd3443a85b7ee8d7d8ac439148aa221922774efe4cf87506d4fb054d5889303
languageName: node
linkType: hard

"locate-path@npm:^3.0.0":
version: 3.0.0
resolution: "locate-path@npm:3.0.0"
Expand Down

0 comments on commit 9a2451f

Please sign in to comment.