Skip to content

Commit

Permalink
Remove dependency on loader-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
nied committed May 4, 2022
1 parent 1f98d3c commit ec08cea
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 69 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -11,7 +11,6 @@
},
"dependencies": {
"find-cache-dir": "^3.3.1",
"loader-utils": "^2.0.0",
"make-dir": "^3.1.0",
"schema-utils": "^2.6.5"
},
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");

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
35 changes: 0 additions & 35 deletions test/cache.test.js
Expand Up @@ -156,41 +156,6 @@ test.serial.cb(
},
);

test.serial.cb(
"should output files to standard cache dir if set to true in query",
t => {
const config = Object.assign({}, globalConfig, {
output: {
path: t.context.directory,
},
module: {
rules: [
{
test: /\.jsx?/,
use: `${babelLoader}?cacheDirectory=true&presets[]=@babel/preset-env`,
exclude: /node_modules/,
},
],
},
});

webpack(config, (err, stats) => {
t.is(err, null);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(defaultCacheDir, (err, files) => {
files = files.filter(file => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file));

t.is(err, null);

t.true(files.length > 0);
t.end();
});
});
},
);

test.cb("should read from cache directory if cached file exists", t => {
const config = Object.assign({}, globalConfig, {
output: {
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
26 changes: 0 additions & 26 deletions yarn.lock
Expand Up @@ -2143,7 +2143,6 @@ __metadata:
find-cache-dir: ^3.3.1
husky: ^4.3.0
lint-staged: ^10.5.1
loader-utils: ^2.0.0
make-dir: ^3.1.0
nyc: ^15.1.0
pnp-webpack-plugin: ^1.6.4
Expand Down Expand Up @@ -2246,13 +2245,6 @@ __metadata:
languageName: node
linkType: hard

"big.js@npm:^5.2.2":
version: 5.2.2
resolution: "big.js@npm:5.2.2"
checksum: ea33d7d25674df4253ae3667da7f48ade6cc8828cb4f2c3a7753f53975f10cebae57e0d1ecf84f1b920b5467262dc0d4f357e5e497b138472d0e64992a8402a4
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 @@ -3220,13 +3212,6 @@ __metadata:
languageName: node
linkType: hard

"emojis-list@npm:^3.0.0":
version: 3.0.0
resolution: "emojis-list@npm:3.0.0"
checksum: a79126b55bc86ee8fd938235a6adf9d457c05fb5bb934e8608b7d35c878d9d1e312a67759244f5c3fba0810b508eb5617e5e6ad6886496ebcfa6832d1c8de3c4
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 @@ -5223,17 +5208,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: c1df0ff0fb52787011b8d19b1e38ee1b67e31d8b301703e6f791256377ce71a6180f40c34a597dfafe76fe621139fea0ee4669344d98b939d9042ea1c32f1ba9
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 ec08cea

Please sign in to comment.