Skip to content

Commit

Permalink
[resolvers] [*] [fix] restore node 6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 8, 2023
1 parent 69fce5c commit 10913e7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
50 changes: 25 additions & 25 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,17 @@
"no-console": "off",
},
},
{
"files": "resolvers/**",
"env": {
"es6": false,
},
},
{
"files": "resolvers/webpack/**",
"rules": {
"no-console": 1,
"prefer-template": 0,
"prefer-object-spread": 0,
"prefer-rest-params": 0,
},
"env": {
"es6": true,
},
},
{
"files": [
"resolvers/*/test/**/*",
"resolvers/**",
"utils/**",
],
"env": {
"mocha": true,
"es6": false
"es6": false,
},
},
{
"files": "utils/**",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaVersion": 2016,
},
"rules": {
"comma-dangle": ["error", {
Expand All @@ -229,11 +209,31 @@
"exports": "always-multiline",
"functions": "never"
}],
"prefer-destructuring": "warn",
"prefer-object-spread": "off",
"prefer-rest-params": "off",
"prefer-spread": "warn",
"prefer-template": "off",
}
},
{
"files": [
"resolvers/webpack/**",
"utils/**",
],
"rules": {
"no-console": 1,
},
},
{
"files": [
"resolvers/*/test/**/*",
],
"env": {
"mocha": true,
"es6": false
},
},
{
"files": "tests/**",
"env": {
Expand Down
6 changes: 3 additions & 3 deletions resolvers/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ exports.resolve = function (source, file, config) {
};

function opts(file, config, packageFilter) {
return { // more closely matches Node (#333)
return Object.assign({ // more closely matches Node (#333)
// plus 'mjs' for native modules! (#939)
extensions: ['.mjs', '.js', '.json', '.node'],
...config,
}, config, {
// path.resolve will handle paths relative to CWD
basedir: path.dirname(path.resolve(file)),
packageFilter,
};
});
}

function identity(x) { return x; }
Expand Down
8 changes: 4 additions & 4 deletions resolvers/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,18 @@ function createWebpack1ResolveSync(webpackRequire, resolveConfig, plugins) {
makeRootPlugin(ModulesInRootPlugin, 'module', resolveConfig.root),
new ModulesInDirectoriesPlugin(
'module',
resolveConfig.modulesDirectories || resolveConfig.modules || ['web_modules', 'node_modules'],
resolveConfig.modulesDirectories || resolveConfig.modules || ['web_modules', 'node_modules']
),
makeRootPlugin(ModulesInRootPlugin, 'module', resolveConfig.fallback),
new ModuleAsFilePlugin('module'),
new ModuleAsDirectoryPlugin('module'),
new DirectoryDescriptionFilePlugin(
'package.json',
['module', 'jsnext:main'].concat(resolveConfig.packageMains || webpack1DefaultMains),
['module', 'jsnext:main'].concat(resolveConfig.packageMains || webpack1DefaultMains)
),
new DirectoryDefaultFilePlugin(['index']),
new FileAppendPlugin(resolveConfig.extensions || ['', '.webpack.js', '.web.js', '.js']),
new ResultSymlinkPlugin(),
new ResultSymlinkPlugin()
);

const resolvePlugins = [];
Expand Down Expand Up @@ -419,7 +419,7 @@ function findConfigPath(configPath, packageDir) {
}

const maybePath = path.resolve(
path.join(packageDir, 'webpack.config' + maybeExtension),
path.join(packageDir, 'webpack.config' + maybeExtension)
);
if (fs.existsSync(maybePath)) {
configPath = maybePath;
Expand Down

0 comments on commit 10913e7

Please sign in to comment.