dojo / core

:rocket: Dojo 2 - language helpers and utilities.
http://dojo.io
Other
213 stars 62 forks source link

Implement AMD-style plugins for `load` and `load/webpack`. #271

Closed mwistrand closed 7 years ago

mwistrand commented 7 years ago

Updates load.ts and load/webpack.ts to allow amdjs-style plugins to be used.

Resolves a portion of #201.

// html-dom-plugin
import { Load, useDefault } from '@dojo/core/load';

export function normalize(resourceId: string, resolver: (mid: string) => string): string {
    return resolver(mid).replace('app-name', 'appName');
}

export function load(mid: string, load: Load): Promise<any> {
    return load(mid).then(useDefault).then((value: string) => htmlToDom(string));
}
load('html-dom-plugin!path/to/html/string').then((htmlTree) => {
    // ...
});
codecov-io commented 7 years ago

Current coverage is 95.19% (diff: 94.11%)

Merging #271 into master will increase coverage by 0.08%

@@             master       #271   diff @@
==========================================
  Files            34         34          
  Lines          1819       1851    +32   
  Methods          19         19          
  Messages          0          0          
  Branches        355        366    +11   
==========================================
+ Hits           1730       1762    +32   
- Misses           27         28     +1   
+ Partials         62         61     -1   

Powered by Codecov. Last update 55cbdb0...1f1fa7a