You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CouchDB JavaScript design functions API includes specialized support for CommonJS module imports. While there is nothing to stop one from using couchster to generate a validation function from document definitions that include the require statement in custom code as is, any attempt to exercise code that depends on a required module with a couchster test fixture will fail since its test fixtures do not support CommonJS module imports.
Add support for importing CommonJS modules that conforms to the constraints outlined in the CouchDB documentation. Notably, module paths are "relative to the design document’s views object, but modules can only be loaded from the object referenced via lib". In other words, a CommonJS module file must be defined at the path views/lib relative to the current working directory to properly simulate the environment in which they will be deployed to a CouchDB design document.
In the meantime, the preferred approach for modularization is via the importDocumentDefinitionFragment macro as documented in the couchster README.
Examples
A valid module import, assuming that a CommonJS module string has been defined in the document at views.lib.time:
vartime=require('views/lib/time');
Note that CouchDB does not seem to allow a dot (.) to indicate the current "directory"/path. For example, this is invalid:
vartime=require('./views/lib/time');
The text was updated successfully, but these errors were encountered:
Feature Request
Description
The CouchDB JavaScript design functions API includes specialized support for CommonJS module imports. While there is nothing to stop one from using couchster to generate a validation function from document definitions that include the
require
statement in custom code as is, any attempt to exercise code that depends on arequire
d module with a couchster test fixture will fail since its test fixtures do not support CommonJS module imports.Add support for importing CommonJS modules that conforms to the constraints outlined in the CouchDB documentation. Notably, module paths are "relative to the design document’s
views
object, but modules can only be loaded from the object referenced vialib
". In other words, a CommonJS module file must be defined at the pathviews/lib
relative to the current working directory to properly simulate the environment in which they will be deployed to a CouchDB design document.In the meantime, the preferred approach for modularization is via the
importDocumentDefinitionFragment
macro as documented in the couchster README.Examples
A valid module import, assuming that a CommonJS module string has been defined in the document at
views.lib.time
:Note that CouchDB does not seem to allow a dot (
.
) to indicate the current "directory"/path. For example, this is invalid:The text was updated successfully, but these errors were encountered: