Skip to content

Commit b0e5282

Browse files
committed
remove moduleExtensions
1 parent 9220c2a commit b0e5282

File tree

6 files changed

+19
-87
lines changed

6 files changed

+19
-87
lines changed

README.md

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,24 @@ For more examples creating different types resolvers (sync/async, context, etc)
5252

5353
#### Resolver Options
5454

55-
| Field | Default | Description |
56-
| ---------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
57-
| alias | [] | A list of module alias configurations or an object which maps key to value |
58-
| aliasFields | [] | A list of alias fields in description files |
59-
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
60-
| descriptionFiles | ["package.json"] | A list of description files to read from |
61-
| enforceExtension | false | Enforce that a extension from extensions must be used |
62-
| enforceModuleExtension | false | Enforce that a extension from moduleExtensions must be used |
63-
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
64-
| mainFields | ["main"] | A list of main fields in description files |
65-
| mainFiles | ["index"] | A list of main files in directories |
66-
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
67-
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
68-
| plugins | [] | A list of additional resolve plugins which should be applied |
69-
| symlinks | true | Whether to resolve symlinks to their symlinked location |
70-
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
71-
| moduleExtensions | [] | A list of module extensions which should be tried for modules |
72-
| resolveToContext | false | Resolve to a context instead of a file |
73-
| fileSystem | | The file system which should be used |
74-
| resolver | undefined | A prepared Resolver to which the plugins are attached |
55+
| Field | Default | Description |
56+
| ---------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
57+
| alias | [] | A list of module alias configurations or an object which maps key to value |
58+
| aliasFields | [] | A list of alias fields in description files |
59+
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
60+
| descriptionFiles | ["package.json"] | A list of description files to read from |
61+
| enforceExtension | false | Enforce that a extension from extensions must be used |
62+
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
63+
| mainFields | ["main"] | A list of main fields in description files |
64+
| mainFiles | ["index"] | A list of main files in directories |
65+
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
66+
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
67+
| plugins | [] | A list of additional resolve plugins which should be applied |
68+
| symlinks | true | Whether to resolve symlinks to their symlinked location |
69+
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
70+
| resolveToContext | false | Resolve to a context instead of a file |
71+
| fileSystem | | The file system which should be used |
72+
| resolver | undefined | A prepared Resolver to which the plugins are attached |
7573

7674
## Plugins
7775

lib/ResolverFactory.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ exports.createResolver = function(options) {
5858
// Enforce that a extension from extensions must be used
5959
const enforceExtension = options.enforceExtension || false;
6060

61-
// A list of module extensions which should be tried for modules
62-
let moduleExtensions = options.moduleExtensions || [];
63-
64-
// Enforce that a extension from moduleExtensions must be used
65-
const enforceModuleExtension = options.enforceModuleExtension || false;
66-
6761
// A list of module alias configurations or an object which maps key to value
6862
let alias = options.alias || [];
6963

@@ -111,7 +105,6 @@ exports.createResolver = function(options) {
111105
}
112106

113107
extensions = [].concat(extensions);
114-
moduleExtensions = [].concat(moduleExtensions);
115108

116109
modules = mergeFilteredToArray([].concat(modules), item => {
117110
return !isAbsolutePath(item);
@@ -160,7 +153,6 @@ exports.createResolver = function(options) {
160153
resolver.ensureHook("describedResolve");
161154
resolver.ensureHook("rawModule");
162155
resolver.ensureHook("module");
163-
resolver.ensureHook("rawResolveInDirectory");
164156
resolver.ensureHook("resolveInDirectory");
165157
resolver.ensureHook("resolveInExistingDirectory");
166158
resolver.ensureHook("relative");
@@ -220,19 +212,7 @@ exports.createResolver = function(options) {
220212
});
221213

222214
// module
223-
plugins.push(new JoinRequestPartPlugin("module", "raw-resolve-in-directory"));
224-
225-
// raw-resolve-in-directory
226-
moduleExtensions.forEach(item => {
227-
plugins.push(
228-
new AppendPlugin("raw-resolve-in-directory", item, "resolve-in-directory")
229-
);
230-
});
231-
if (!enforceModuleExtension) {
232-
plugins.push(
233-
new NextPlugin("raw-resolve-in-directory", "resolve-in-directory")
234-
);
235-
}
215+
plugins.push(new JoinRequestPartPlugin("module", "resolve-in-directory"));
236216

237217
// resolve-in-directory
238218
plugins.push(

test/fixtures/node_modules/l-loader.js

Whitespace-only changes.

test/fixtures/node_modules/m2-loader/b.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/fixtures/node_modules/m2-loader/c.js

Whitespace-only changes.

test/resolve.js

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ const syncContextResolve = resolve.create.sync({
1818
resolveToContext: true
1919
});
2020

21-
const asyncLoaderResolve = resolve.create({
22-
extensions: [".js", ".json", ".node"],
23-
moduleExtensions: ["-loader"],
24-
mainFields: ["loader", "main"]
25-
});
26-
27-
const syncLoaderResolve = resolve.create.sync({
28-
extensions: [".js", ".json", ".node"],
29-
moduleExtensions: ["-loader"],
30-
mainFields: ["loader", "main"]
31-
});
32-
3321
function testResolve(name, context, moduleName, result) {
3422
describe(name, function() {
3523
it("should resolve sync correctly", function() {
@@ -48,24 +36,6 @@ function testResolve(name, context, moduleName, result) {
4836
});
4937
}
5038

51-
function testResolveLoader(name, context, moduleName, result) {
52-
describe(name, function() {
53-
it("should resolve sync correctly", function() {
54-
var filename = syncLoaderResolve(context, moduleName);
55-
should.exist(filename);
56-
filename.should.equal(result);
57-
});
58-
it("should resolve async correctly", function(done) {
59-
asyncLoaderResolve(context, moduleName, function(err, filename) {
60-
if (err) return done(err);
61-
should.exist(filename);
62-
filename.should.equal(result);
63-
done();
64-
});
65-
});
66-
});
67-
}
68-
6939
function testResolveContext(name, context, moduleName, result) {
7040
describe(name, function() {
7141
it("should resolve async correctly", function(done) {
@@ -205,19 +175,6 @@ describe("resolve", function() {
205175
path.join(fixtures, "dirOrFile", "index.js")
206176
);
207177

208-
testResolveLoader(
209-
"loader with template without extension",
210-
fixtures,
211-
"m2/b",
212-
path.join(fixtures, "node_modules", "m2-loader", "b.js")
213-
);
214-
testResolveLoader(
215-
"loader with template as file",
216-
fixtures,
217-
"l",
218-
path.join(fixtures, "node_modules", "l-loader.js")
219-
);
220-
221178
testResolve(
222179
"find node_modules outside of node_modules",
223180
path.join(fixtures, "browser-module", "node_modules"),

0 commit comments

Comments
 (0)