Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Extension API Evolution: module loader #4986

Open
@jrburke

Description

@jrburke

I came across the Extension API research:
https://github.com/adobe/brackets/wiki/Extension-API-Research

and curious to know if you need any background or ideas on how to use an AMD loader more effectively for what you need.

The main issue seemed to be using modules installed via NPM in brackets for brackets extensions. This would work out better if there was a process that added a bridge module in the node_modules directory to the "main" module in the node_modules area. Then setting the loader's baseUrl config to 'node_modules' would work out.

This assumes that the packages installed do not have nested node_modules dependencies. At first thought I would expect you would not want that anyway given that it meant extra code getting downloaded for in-browser use. However, they could be supported in an AMD loader by using map config if they were desired.

I have an in-process project to write out those adapter modules for node_modules, then also to convert them to AMD format by just adding a define() around the modules installed. Although, I think it is completely fine to also just author the modules in AMD format. People are already using npm for non-node, browser only code, so a concern about module format should not be an issue. But either way, a post-install tool that sets up the bridge modules could also optionally wrap the modules.

If you need some of those same modules to run in a backing node process, r.js can be used in node to load those modules in node, and it could reuse the same config you use for the front end.

This way you could take advantage of the callback require() available in AMD loaders as well as loader plugins, for things like text files, template and transpiled languages. Both of those features have companions in ES6 Modules space, so I expect it will be easy to transition use of them to ES6. The callback require for delayed loading of front end code is also a pretty standard feature request for a project the size of Brackets.

You may have other requirements I have missed, so just offering help in case you think an additional exploration down this path might be useful. No worries though if you have it sorted.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions