From e5712909a098b752aa5fe2570dd0b9b6109e6f83 Mon Sep 17 00:00:00 2001 From: Jon Wallsten Date: Tue, 20 Apr 2021 19:04:15 +0200 Subject: [PATCH] fix: Removed usage of loader-utils (#1288) --- CHANGELOG.md | 4 +++ package.json | 3 +-- src/index.ts | 7 ++--- src/typings/loaderUtils/loaderUtils.d.ts | 5 ---- yarn.lock | 33 +++++------------------- 5 files changed, 13 insertions(+), 39 deletions(-) delete mode 100644 src/typings/loaderUtils/loaderUtils.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 468b24ffe..34e83849d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v9.0.2 + +* [Remove usage of loader-utils](https://github.com/TypeStrong/ts-loader/pull/1287) - thanks @jonwallsten + ## v9.0.1 * [Use correct hook for emitting additional assets during compilation](https://github.com/TypeStrong/ts-loader/pull/1286) - thanks @jonwallsten diff --git a/package.json b/package.json index 05317cfa8..a4a57d5ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-loader", - "version": "9.0.1", + "version": "9.0.2", "description": "TypeScript loader for webpack", "main": "index.js", "types": "dist", @@ -56,7 +56,6 @@ "dependencies": { "chalk": "^4.1.0", "enhanced-resolve": "^5.0.0", - "loader-utils": "^2.0.0", "micromatch": "^4.0.0", "semver": "^7.3.4" }, diff --git a/src/index.ts b/src/index.ts index 1168aa0b9..45b95a5f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import * as crypto from 'crypto'; -import * as loaderUtils from 'loader-utils'; import * as path from 'path'; import type * as typescript from 'typescript'; @@ -174,9 +173,7 @@ function getOptionsHash(loaderOptions: LoaderOptions) { * or creates them, adds them to the cache and returns */ function getLoaderOptions(loaderContext: WebpackLoaderContext) { - const loaderOptions = - loaderUtils.getOptions(loaderContext) || - ({} as LoaderOptions); + const loaderOptions = loaderContext.getOptions(undefined); // If no instance name is given in the options, use the hash of the loader options // In this way, if different options are given the instances will be different @@ -646,7 +643,7 @@ function makeSourceMap( return { output: outputText.replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, ''), sourceMap: Object.assign(JSON.parse(sourceMapText), { - sources: [loaderUtils.getRemainingRequest(loaderContext)], + sources: [loaderContext.remainingRequest], file: filePath, sourcesContent: [contents], }), diff --git a/src/typings/loaderUtils/loaderUtils.d.ts b/src/typings/loaderUtils/loaderUtils.d.ts deleted file mode 100644 index d38ce3ef5..000000000 --- a/src/typings/loaderUtils/loaderUtils.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module 'loader-utils' { - export function getOptions(loaderContext: any): T; - export function getRemainingRequest(loaderContext: any): any; - export function getCurrentRequest(loaderContext: any): any; -} diff --git a/yarn.lock b/yarn.lock index 072df4ed5..cb0790707 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1829,14 +1829,9 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -emojis-list@^2.0.0: - version "2.1.0" - resolved "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" - integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k= - emojis-list@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== encodeurl@~1.0.2: @@ -3171,13 +3166,6 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" -json5@^2.1.2: - version "2.1.3" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.3.tgz#c9b0f7fa9233bfe5807fe66fcf3a5617ed597d43" - integrity sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA== - dependencies: - minimist "^1.2.5" - jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -3399,22 +3387,13 @@ loader-runner@^4.2.0: integrity sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw== loader-utils@^1.0.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7" - integrity sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA== - dependencies: - big.js "^5.2.2" - emojis-list "^2.0.0" - json5 "^1.0.1" - -loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== + version "1.4.0" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" + integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== dependencies: big.js "^5.2.2" emojis-list "^3.0.0" - json5 "^2.1.2" + json5 "^1.0.1" locate-path@^2.0.0: version "2.0.0" @@ -3680,7 +3659,7 @@ minimist@0.0.8: resolved "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= -minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.2.0: version "1.2.5" resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==