Skip to content

Support customized async module resolution #3937

Open
@jimmywarting

Description

@jimmywarting

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featFeature Request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions