google / google/closure-compiler

Support customized async module resolution

Open
#3,937 0 comments 0 reactions 0 assignees View on GitHub
feat
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

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.

```js
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
})
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.