Skip to content

Commit

Permalink
Fix require to look in bundle *after* filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Apr 17, 2017
1 parent 4dbbfa2 commit c8da7e7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions deps/require.lua
Expand Up @@ -179,9 +179,16 @@ local function moduleRequire(base, name)
end
end

-- Stop at filesystem or prefix root (58 is ":")
if base == "/" or base:byte(-1) == 58 then break end
base = pathJoin(base, "..")
if base == "/" then
-- If we reach filesystem root, look in root on bundle
base = "bundle:"
elseif base:byte(-1) == 58 then
-- If we reach root of bundle, it doesn't exist
break
else
-- Otherwise, keep going higher
base = pathJoin(base, "..")
end
end
end

Expand Down

4 comments on commit c8da7e7

@zhaozg
Copy link
Member

@zhaozg zhaozg commented on c8da7e7 Apr 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why look in bundle after filesystem, have enough reasons?

HEAD~4 to HEAD broken a lots my projects.

I vote reset --hard head~4. or return the option to the user by come custom policy.

@zhaozg
Copy link
Member

@zhaozg zhaozg commented on c8da7e7 Apr 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my projects back after use #970

@creationix
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason we need to look in bundle after filesystem (only for non bundle modules) is because sometimes there are conflicting versions of a package in both deps on disk and deps in luvit itself. If require always looks in bundle first, then none of the libraries that are inside luvit can ever be used outside. In particular, I have conflicting versions of http-codec between lit's ecosystem and luvit's builtin libraries.

@zhaozg
Copy link
Member

@zhaozg zhaozg commented on c8da7e7 Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense.

Please sign in to comment.