Skip to content

Commit

Permalink
Update dependencies and drop Node.js < 18 support
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Apr 5, 2024
1 parent 29fec2c commit 5c6eb7c
Show file tree
Hide file tree
Showing 6 changed files with 2,202 additions and 7,531 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [14, 16, 18, 20]
node: [18, 20]

steps:
- name: Clone repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
FORCE_COLOR: 2
NODE: 18
NODE: 20

permissions:
contents: read
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

34 changes: 13 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ module.exports = function(options = {}) {

if (!resolver) {
debug('using generic resolver');
if (!resolveDependencyPath) {
resolveDependencyPath = require('resolve-dependency-path');
}
resolveDependencyPath ||= require('resolve-dependency-path');

resolver = resolveDependencyPath;
}
Expand Down Expand Up @@ -114,9 +112,7 @@ module.exports.unregister = function(extension) {
* @return {String}
*/
module.exports._getJSType = function(options = {}) {
if (!getModuleType) {
getModuleType = require('module-definition');
}
getModuleType ||= require('module-definition');

if (options.config) {
return 'amd';
Expand All @@ -136,9 +132,7 @@ module.exports._getJSType = function(options = {}) {
};

function getCompilerOptionsFromTsConfig(tsConfig) {
if (!ts) {
ts = require('typescript');
}
ts ||= require('typescript');

debug(`given typescript config: ${tsConfig}`);
let compilerOptions = {};
Expand Down Expand Up @@ -195,9 +189,7 @@ function jsLookup(options) {
switch (type) {
case 'amd': {
debug('using amd resolver');
if (!amdLookup) {
amdLookup = require('module-lookup-amd');
}
amdLookup ||= require('module-lookup-amd');

return amdLookup({
config,
Expand All @@ -217,7 +209,9 @@ function jsLookup(options) {

case 'webpack': {
debug('using webpack resolver for es6');
return resolveWebpackPath({ dependency, filename, directory, webpackConfig });
return resolveWebpackPath({
dependency, filename, directory, webpackConfig
});
}

default: {
Expand All @@ -230,12 +224,14 @@ function tsLookup({ dependency, filename, directory, webpackConfig, tsConfig, ts
debug('performing a typescript lookup');

if (typeof tsConfig === 'string') {
tsConfigPath = tsConfigPath || path.dirname(tsConfig);
tsConfigPath ||= path.dirname(tsConfig);
}

if (!tsConfig && webpackConfig) {
debug('using webpack resolver for typescript');
return resolveWebpackPath({ dependency, filename, directory, webpackConfig });
return resolveWebpackPath({
dependency, filename, directory, webpackConfig
});
}

const compilerOptions = getCompilerOptionsFromTsConfig(tsConfig);
Expand Down Expand Up @@ -328,9 +324,7 @@ function commonJSLookup(options) {
const { filename, directory, nodeModulesConfig, tsConfig } = options;
let { dependency } = options;

if (!resolve) {
resolve = require('resolve');
}
resolve ||= require('resolve');

if (!dependency) {
debug('blank dependency given. Returning early.');
Expand Down Expand Up @@ -422,9 +416,7 @@ function vueLookup(options) {
}

function resolveWebpackPath({ dependency, filename, directory, webpackConfig }) {
if (!webpackResolve) {
webpackResolve = require('enhanced-resolve');
}
webpackResolve ||= require('enhanced-resolve');

webpackConfig = path.resolve(webpackConfig);
let loadedConfig;
Expand Down
Loading

0 comments on commit 5c6eb7c

Please sign in to comment.