GithubHelp home page GithubHelp logo

for Scripted about enhanced-resolve HOT 7 CLOSED

webpack avatar webpack commented on May 5, 2024
for Scripted

from enhanced-resolve.

Comments (7)

kdvolder avatar kdvolder commented on May 5, 2024

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.

sokra avatar sokra commented on May 5, 2024

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.

kdvolder avatar kdvolder commented on May 5, 2024

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.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.


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-9942731.

from enhanced-resolve.

sokra avatar sokra commented on May 5, 2024

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.

kdvolder avatar kdvolder commented on May 5, 2024

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.

sokra avatar sokra commented on May 5, 2024

https://github.com/webpack/enhanced-resolve/wiki/Common-Options

from enhanced-resolve.

sokra avatar sokra commented on May 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.