File tree Expand file tree Collapse file tree 1 file changed +22
-21
lines changed Expand file tree Collapse file tree 1 file changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -9,47 +9,48 @@ npm install @masx200/rollup-plugin-http-resolve --save
99``` ts
1010import { fileCache , httpResolve } from " @masx200/rollup-plugin-http-resolve" ;
1111
12- httpResolve ({ cache: new fileCache () })
13- ```
12+ httpResolve ({ cache: new fileCache () });
13+ ```
14+
1415## Example
1516
1617``` ts
1718// rollup.config.js
1819import { httpResolve } from " @masx200/rollup-plugin-http-resolve" ;
1920export default {
20- input: " index.js" ,
21- plugins: [
22- httpResolve ({
23- cache ,
24- }),
25- ],
21+ input: " index.js" ,
22+ plugins: [
23+ httpResolve ({
24+ cache ,
25+ }),
26+ ],
2627};
2728```
2829
2930## Example: CDN Resolve
3031
3132``` ts
3233const vol = Volume .fromJSON ({
33- " /index.js" : `
34+ " /index.js" : `
3435 import {h} from "preact";
3536 console.log(h);
3637 ` ,
3738});
3839
3940const memfs = createFs (vol ) as IPromisesAPI ;
4041const rolled = await rollup ({
41- input: " /index.js" ,
42- plugins: [
43- httpResolve ({
44- fallback(id ) {
45- // Avoid local relative path
46- if (! id .startsWith (" ." )) {
47- return ` https://esm.sh/${id } ` ;
48- }
49- },
50- }),
51- memfsPlugin (memfs ),
52- ],
42+ input: " /index.js" ,
43+ plugins: [
44+ httpResolve ({
45+ fallback(id ) {
46+ // Avoid local relative path
47+ if (! id .startsWith (" ." )) {
48+ return ` https://esm.sh/${id } ` ;
49+ }
50+ },
51+ }),
52+ memfsPlugin (memfs ),
53+ ],
5354});
5455const out = await rolled .generate ({ format: " es" });
5556const code = out .output [0 ].code ;
You can’t perform that action at this time.
0 commit comments