Commit Graph

40 Commits (c24276f0087a5f72f68be2384f32e20ba83dfa09)

Author SHA1 Message Date
Igor Zinkovsky 7335a4234a fix test-module-loading on windows 2011-11-04 18:05:53 -07:00
Ryan Dahl 850609ea2d Remove separation of libuv tests 2011-11-02 16:38:59 -07:00
Ben Noordhuis 018e110cd1 test: replace .addListener() calls with .on() 2011-10-15 01:08:36 +02:00
Colton Baker 87286cc737 Fixed a lot of jslint errors.
Fixes 
2011-10-05 18:51:06 -07:00
Ryan Dahl 4e1d6fca8e Mark tests which are broken in libuv 2011-08-23 23:45:21 -07:00
Ben Noordhuis ac722bbed6 module: strip byte order marker when loading *.js and *.json files
BOMs make V8 raise a 'SyntaxError: Unexpected token ILLEGAL' exception.

Fixes .
2011-08-04 16:52:55 +02:00
isaacs 703a1ffe52 Revert "AMD compatibility for node"
This reverts commit 9967c369c9.

Conflicts:

	test/simple/test-module-loading.js
2011-07-29 11:56:38 -07:00
isaacs 588d885e81 Close Load json files with require()
Signed off by everybody.
2011-07-20 17:39:23 -07:00
isaacs 7f0047c2d5 Close Remove require.paths
Module.globalPaths is still set to a read-only copy of the global
include paths pulled off of the NODE_PATH environment variable.

It's important to be able to inspect this, but modifying it no longer
has any effect.
2011-07-15 15:11:33 -07:00
isaacs 9b5098f509 Close Make require a public member of module
Reviewed by @felixge
2011-07-14 14:25:49 -07:00
isaacs 9967c369c9 AMD compatibility for node, with docs and tests
Closes 
Closes 
2011-06-13 16:11:13 -07:00
Ryan Dahl 55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
isaacs f8defa3e09 package.json main as indexed subdir
Closes GH-686.
2011-02-18 10:43:06 -08:00
isaacs 46513483cd node_modules module lookup, +docs and test. 2011-02-09 14:24:22 -08:00
isaacs da2f4b2dc4 support for package.json
This adds basic support for situations where there is a package.json
with a "main" field.  That "main" module is used as the code that is
loaded when the package folder is required.
2011-02-07 11:00:22 -08:00
isaacs f86ec1366f Closes GH-619 Make require.main be the main module 2011-02-02 11:18:34 -08:00
Ryan Dahl fbb74784b5 Remove more process.assert 2011-01-27 17:02:25 -08:00
isaacs 6cdeb3b3fd A module ID with a trailing slash must be a dir.
require('./foo/') should not try to load './foo.js'.  It should only
look for ./foo/index.js

Closes GH-588
2011-01-27 14:02:43 -08:00
Oleg Efimov 0ce9cbab29 GJSLint continue 2010-12-05 09:28:18 -08:00
Ryan Dahl a0159b4b29 Fix global leaks 2010-12-04 15:58:50 -08:00
Anders Conbere c4f8f871c9 adding module tests for .js and bare files
Currently the module tests don't cover the cases for when a user
requires a file with a request that includes the extension, and for a
request to a file with no extensions.

ex.

require("./a.js") // not tested
require("./foo") // (not tested with trying to load a file named ./foo)
2010-12-03 16:00:10 -08:00
isaacs dff1b5ad10 Don't try to run extension loaders unless they're actually functions 2010-09-22 10:13:25 -07:00
Tim-Smart 0f16af7ee4 Remove registerExtension, add .extensions. Tests.
Updated extensions tests
2010-09-20 09:56:43 -07:00
isaacs bb08f0c219 Remove require.async
This patch removes require.async from nodejs.

1. It complicated the code unnecessarily.
2. Everyone uses sync require anyway.
3. It's got a lot of weird edge cases when mixed with sync require.
4. It is many months behind the commonjs spec anyhow.
2010-09-19 16:52:39 -07:00
Herbert Vojčík 9253333850 Fix registerExtension for NODE_MODULE_CONTEXTS
Fix of registerExtension-produced non-string module loading with own
context. Plus finishing touches to the test.
2010-08-18 11:46:37 -07:00
Herbert Vojčík cf2b206a8e More changes to tests so they really work under context module loader.
Plus, getting rid of test/common.js defining things in global.
2010-08-17 08:41:05 -07:00
Ryan Dahl 03123435e0 Remove platform specific asserts 2010-08-13 08:13:54 -07:00
Nick Stenning 0a3eff8021 Standardise module load order for native and registered file extensions.
This patch standardises the load order for modules. Highest priority is trying to load exactly the file the user specified, followed by native extensions, followed by registered extra extensions, etc.

In full, if we require('foo') having registered '.coffee' as an alternative extension, we try and load the following files in order:

    foo
    foo.js
    foo.node
    foo.coffee
    foo/index.js
    foo/index.node
    foo/index.coffee
2010-08-04 16:03:08 -07:00
Nick Stenning 78520ba482 Don't attempt to load a directory.
This patch replaces the path.exists check for module loading with a call to
fs.statSync (or fs.stat for require.async) which ensures that it's not trying
to load a directory.
2010-08-04 15:55:47 -07:00
isaacs d75b63bc3c Support including modules that don't have an extension.
This way, require("/foo") will work if there is a "foo.js", or a file named
simply "foo" with no extension.
2010-07-20 10:26:24 -07:00
isaacs 49e0f14a2f Cache modules based on filename rather than ID
This is ever so slightly less efficient than caching based on ID, since the
filename has to be looked up before we can check the cache.  However, it's
the most minimal approach possible to get this change in place.  Since
require() is a blocking startup-time operation anyway, a bit of slowness is
not a huge problem.

A test involving require.paths modification and absolute loading. Here's the
gist of it.

Files: /p1/foo.js /p2/foo.js

  1. Add "/p1" to require.paths.
  2. foo1 = require("foo")
  3. assert foo1 === require("/p1/foo") (fail)
  4. Remove /p1 from require.paths.
  5. Add /p2 to require.paths.
  6. foo2 = require("foo")
  7. assert foo1 !== foo2 (fail)
  8. assert foo2 === require("/p2/foo") (fail)

It's an edge case, but it affects how dependencies are mapped by npm.
If your module requires foo-1.2.3, and my module requires foo-2.3.4,
then you should expect to have require("foo") give you foo-1.2.3, and
I should expect require("foo") to give me foo-2.3.4.  However, with
module ID based caching, if your code loads *first*, then your "foo"
is THE "foo", so I'll get your version instead of mine.

It hasn't yet been a problem, but only because there are so few
modules, and everyone pretty much uses the latest version all the
time.  But as things start to get to the 1.x and 2.x versions, it'll
be an issue, I'm sure.  Dependency hell isn't fun, so this is a way to
avoid it before it strikes.
2010-07-19 14:17:22 -07:00
Ryan Dahl 9fd5e3c89c Update tests to work with module contexts 2010-07-15 14:21:31 -07:00
David Siegel 2085909aeb fix corner-case bug in Module
and added a test to expose it
2010-07-13 17:15:10 -07:00
Ryan Dahl ba792ea202 :%s/sys.puts/console.log/g
and there was much rejoicing
2010-06-23 20:05:29 -07:00
Herbert Vojcik c16508c87a Better require.async throw test 2010-04-08 08:17:58 -07:00
Herbert Vojcik d36bb6536e Better require.async tests 2010-04-07 11:47:45 -07:00
Tim-Smart 0c17067d87 Add require.registerExtension 2010-03-11 22:00:55 -08:00
isaacs 5861db8a69 Remove process.mixin dependency from all tests. 2010-03-08 17:57:04 -08:00
Felix Geisendörfer 44dde5f24c Remove fs/path globals from test suite
It is way too easy to not notice bugs due to those modules being
exported as globals while running the test suite.

See: http://github.com/ry/node/issues#issue/75
2010-03-08 10:20:07 -08:00
arlolra 04fac19822 Split tests. 2010-02-25 11:41:11 -08:00