Comments (7)
It does a bit of caching. It caches every io call for a short amount of time (currently fixed to 4 seconds), ...
Thanks for correcting my misunderstanding. This is good to know. Also a short-lived 4 second cache, I think that's fine. My assumption is really that changes to installed node modules are relatively rare. So this is not likely to cause any issue.
Actually, I'd be inclined to increase the lifetime of the cache... maybe with an explicit 'clear button' so the client has some way of explicitly flushing the cache at specific times / events.
Thanks for your comments. You've convinced me that it will be best for scripted to ditch its 'home baked' node resolution and use enhanced-resolve. It seems we will be able to work with you and contribute patches to get stuff/hooks we need :-)
from enhanced-resolve.
Here is some documentation and the (wip) next version: https://github.com/webpack/enhanced-resolve/tree/wip-0.4
Checkout this file for your filesystem issue: https://github.com/webpack/enhanced-resolve/blob/wip-0.4/lib/cachedFsResolve.js
It also allows to make own caching logic.
It now supports query strings in requests. You'll need this if you want to support require.js (and I want to add this feature to webpack).
And one bugfix which caused in a rar double error case the callback to be invoked two times.
from enhanced-resolve.
Thanks Tobias, that's great. Especially the documentation is very useful to
help me use your library.
Note that most of the 'concerns' I expressed about the library are not
really urgent. Currently I think the library does pretty much what we want.
I was just looking ahead and anticipating a need in the future to use
different filesystem implementation and/or JSON parsers etc.
None of these are really things we need right this moment.
Kris
On Wed, Oct 31, 2012 at 5:26 AM, Tobias Koppers [email protected]:
Here is some documentation and the (wip) next version:
https://github.com/webpack/enhanced-resolve/tree/wip-0.4Checkout this file for your filesystem issue:
https://github.com/webpack/enhanced-resolve/blob/wip-0.4/lib/cachedFsResolve.jsIt also allows to make own caching logic.
It now supports query strings in requests. You'll need this if you want to
support require.js (and I want to add this feature to webpack).And one bugfix which caused in a rar double error case the callback to be
invoked two times.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-9942731.
from enhanced-resolve.
So I've added the completion feature: (beta!)
You can use the resolve.complete
method and pass a incomplete require string. The string must contain exactly one *
, which indicates the insert postion (cursor position). The function returns an array of possible strings the user can input (or choose from).
resolve.complete.sync(/* context = */ __dirname, "enhanced-re*", /* optional options = */ {});
// returns
[
{
insert: "solve",
seqment: "enhanced-resolve",
part: "enhanced-resolve",
result: "enhanced-resolve"
}, {
insert: "quire",
seqment: "enhanced-require",
part: "enhanced-require",
result: "enhanced-require"
}
]
"enhanced-resolve/l*/resolve" ->
[
{
insert: "ib",
seqment: "lib",
part: "enhanced-resolve/lib/resolve",
result: "enhanced-resolve/lib/resolve"
}
]
"enhanced-resolve/lib*/resolve" ->
[
{
insert: "",
seqment: "lib",
part: "enhanced-resolve/lib/resolve",
result: "enhanced-resolve/lib/resolve"
}
] // already valid entry returns with insert == ""
"enhanced-resolve/liba*/resolve" ->
// invalid entry in at current position returns empty array
[]
"enhanced-resolve/liba/resolve*" ->
throws error "liba" not found
Here is a simple playground executable to play with the code completion:
https://gist.github.com/4021254
from enhanced-resolve.
Looks very useful! I've added a link to a relevant Jira issue in our bugtracker to point here:
https://issuetracker.springsource.com/browse/SCRIPTED-27
Tobias, currently I have two separate resolver algorithms in scripted. The node/commonjs resolver is just a wrapper around 'enhanced-resolve'.
But the amd resolver is still 'home-baked'. I'm not quite sure if it is possible to configure enhanced-resolve so it can assume the role of an amd resolver. If possible, I think that would be preferable though. Do you have some ideas on that?
The reason why I'm uncertain about this is that it looks to me the amd algos are a bit different than what happens in node. Rather than looking through and trying a number of different places (several dirs, extensions, package.json etc)... it looks like AMD loaders like requirejs and curl tend to just take a module name, some config data and from that derive a single path where the module must be loaded from. So it seems a lot less 'searchy' to me.
I'm really still learning how all this stuff works, so my ideas on this are surely naive and may even be totally incorrect.
So, Im very interested in hearing your thoughts on using enhanced-resolve for amd-resolution.
Kris
from enhanced-resolve.
https://github.com/webpack/enhanced-resolve/wiki/Common-Options
from enhanced-resolve.
A cool demo for require completion: http://webpack.github.com/enhanced-resolve-completion-demo/
Type in the input, up and down arrow, enter, click...
from enhanced-resolve.
Related Issues (20)
- virtual module not found error HOT 1
- add type defines for `CachedInputFileSystem` ? HOT 5
- CachedInputFileSystem OOM when duration is infinity HOT 5
- signature of method `stat` in interface `FileSystem` mismatches. HOT 2
- bug: exports map key with star in the middle doesn't work HOT 1
- is this possible with webpack AliasPlugin to automatically switch to a different alias when original file is deleted? HOT 7
- can't resolve exports pattern startsWith wildcards HOT 1
- Use of `extensionAlias` fails resolution of subpath exports in `exports` fields HOT 2
- resolving packages entrypoints with a non-standard node_modules HOT 4
- `exports.types` after `exports.default` HOT 5
- Hooks do not fire events from CSS/SCSS imports HOT 6
- AliasPlugin crash when file is deleted or rename (have to restart to make it work)
- Seeing "Error: No file content" for different package.json files when webpack rebuilds HOT 1
- ESM: Resolving to the wrong package with `exports` and nested same package but different versions HOT 3
- ESM: package.exports array target not conforming to the ESM specification HOT 10
- Add ability to handle win32 relative paths HOT 4
- [Feature Request]: Support resolve the modules with hard-links HOT 4
- lstat error when requiring virtual modules HOT 1
- Can i use withOptions Api ? HOT 1
- File Extension Substitution for TypeScript Support HOT 18
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from enhanced-resolve.