closure-compiler icon indicating copy to clipboard operation
closure-compiler copied to clipboard

Support customized async module resolution

Open jimmywarting opened this issue 3 years ago • 0 comments

Something that is quite handy in nodejs es module is the possibility to specify module loaders.

This allows developer to customize how modules are resolved... with this you could also be able to fetch remote stuff from cdn also esbuild also have something similar https://esbuild.github.io/plugins/#http-plugin node has it also: https://nodejs.org/dist/latest-v17.x/docs/api/esm.html#https-loader I'm sure webpack do to...

This could allow developer to hook into something like a virtual filesystem and making it a bit less dependent on the operation system.

import { compiler as ClosureCompiler } = require('google-closure-compiler')
import httpLoader from './https-loader.mjs'

async function httpLoader (url, context, defaultLoad) {
  // ...
}

const closureCompiler = new ClosureCompiler({
  js: 'file-one.js',
  compilation_level: 'ADVANCED',
  load: httpLoader
})

jimmywarting avatar Apr 19 '22 10:04 jimmywarting