Skip to content

Commit c561d2a

Browse files
committed
Even simpler way to register cjs
1 parent fb3e381 commit c561d2a

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

coffeescript-loader/loader.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ async function getPackageType(url) {
8484
return dir.length > 1 && getPackageType(resolvePath(dir, '..'));
8585
}
8686

87-
88-
// Register CoffeeScript to also transform CommonJS files. This can more
89-
// thoroughly be done for CoffeeScript specifically via
90-
// `CoffeeScript.register()`, but for purposes of this example this is the
91-
// simplest method.
87+
// Register CoffeeScript to also transform CommonJS files.
9288
const require = createRequire(import.meta.url);
93-
['.coffee', '.litcoffee', '.coffee.md'].forEach(extension => {
94-
require.extensions[extension] = (module, filename) => {
95-
const source = readFileSync(filename, 'utf8');
96-
return module._compile(coffeeCompile(source, filename), filename);
97-
}
98-
})
89+
require("coffeescript/register")

0 commit comments

Comments
 (0)