Comparing version 0.3.10 to 0.4.0
21
index.js
@@ -25,4 +25,4 @@ var extensions = { | ||
var register = { | ||
'node-jsx': function (module) { | ||
module.install({ extension: '.jsx', harmony: true }); | ||
'node-jsx': function (module, config) { | ||
module.install(config); | ||
}, | ||
@@ -34,2 +34,17 @@ 'toml-require': function (module) { | ||
var legacyModules = { | ||
'.coffee': 'coffee-script', | ||
'.coffee.md': 'coffee-script', | ||
'.iced': 'iced-coffee-script', | ||
// .iced.md and .liticed weren't available before the register module | ||
'.litcoffee': 'coffee-script' | ||
}; | ||
var configurations = { | ||
'node-jsx': { | ||
extension: '.jsx', | ||
harmony: true | ||
} | ||
}; | ||
var jsVariantExtensions = [ | ||
@@ -52,2 +67,4 @@ '.js', | ||
extensions: extensions, | ||
legacy: legacyModules, | ||
configurations: configurations, | ||
register: register, | ||
@@ -54,0 +71,0 @@ jsVariants: jsVariantExtensions.reduce(function (result, ext) { |
{ | ||
"name": "interpret", | ||
"description": "A dictionary of file extensions and associated module loaders.", | ||
"version": "0.3.10", | ||
"version": "0.4.0", | ||
"homepage": "https://github.com/tkellen/node-interpret", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -38,2 +38,11 @@ # interpret | ||
### legacy | ||
Check here to see if a legacy module should be loaded upon failure to load the main module. If a legacy module is available | ||
it is recommended to use `try/catch` around the `require`s to avoid crashing the process upon failure to load the main module. | ||
```js | ||
{ | ||
'.coffee': 'coffee-script' // old versions of coffee-script didn't have the `register` module | ||
} | ||
``` | ||
### register | ||
@@ -49,2 +58,20 @@ Check here to see if setup is needed for the module register itself with [require.extensions]. If a method is returned, call it with the module. | ||
### configurations | ||
These configuration options should be passed into any `register` function with the same key. | ||
```js | ||
// configurations | ||
{ | ||
'node-jsx': { | ||
extension: '.jsx', | ||
harmony: true | ||
} | ||
} | ||
// register | ||
{ | ||
'node-jsx': function (module, config) { | ||
module.install(config); | ||
} | ||
} | ||
``` | ||
### jsVariants | ||
@@ -97,3 +124,4 @@ Extensions which are javascript variants. | ||
// find the module relative to cwd that can add support for this extension | ||
var module = resolve.sync(moduleName, {basedir: cwd}) | ||
// optionally deal with legacy modules here | ||
var module = resolve.sync(moduleName, {basedir: cwd}); | ||
// require it | ||
@@ -103,5 +131,6 @@ var compiler = require(module); | ||
var register = interpret.register[moduleName]; | ||
var config = interpret.configurations[moduleName]; | ||
// if there is, run it | ||
if (register) { | ||
register(compiler); | ||
register(compiler, config); | ||
} | ||
@@ -108,0 +137,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8374
67
138