aboutsummaryrefslogtreecommitdiff
path: root/node_modules/require-precompiled/index.js
blob: 3e6f18a69ba3d16cb9093192e047bcb3221592a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';
module.exports = install;

function install(precompile, ext, extensions) {
	ext = ext || '.js';
	extensions = extensions || require.extensions;

	var oldExtension = extensions[ext];

	extensions[ext] = function (module, filename) {
		var source = precompile(filename);
		if (source) {
			module._compile(source, filename);
			return;
		}
		oldExtension(module, filename);
	};
}