@@ -17,49 +17,32 @@ documentation(s).
17
17
18
18
``` html
19
19
<script type =" module" >
20
- window .addEventListener (' DOMContentLoaded' , async () => {
21
- const Pandino = (await import (' ./pandino.mjs' )).default ;
20
+ import loaderConfiguration from ' https://unpkg.com/@pandino/loader-configuration-dom/dist/loader-configuration-dom.mjs' ;
21
+ import Pandino from ' https://unpkg.com/@pandino/pandino/dist/esm/pandino.mjs' ;
22
+
22
23
const pandino = new Pandino ({
23
- ' pandino.deployment.root' : location .href ,
24
- ' pandino.bundle.importer' : {
25
- import : (deploymentRoot , activatorLocation ) => import (activatorLocation),
26
- },
27
- ' pandino.manifest.fetcher' : {
28
- fetch: async (deploymentRoot , uri ) => (await fetch (uri)).json (),
29
- },
24
+ ... loaderConfiguration,
30
25
});
31
-
26
+
32
27
await pandino .init ();
33
28
await pandino .start ();
34
-
29
+
35
30
console .log (pandino .getBundleContext ());
36
- });
37
31
</script >
38
32
```
39
33
40
34
## Adding Pandino to a TypeScript project (e.g. with Webpack)
41
35
42
- Install Pandino via ` npm install --save @pandino/pandino @pandino/pandino-api ` .
36
+ Install Pandino via ` npm install --save @pandino/pandino @pandino/loader-configuration-dom ` .
43
37
44
38
Initialize it somewhere close in you applications own init logic, e.g.:
45
39
46
40
``` typescript
47
41
import Pandino from ' @pandino/pandino' ;
48
- import {
49
- PANDINO_MANIFEST_FETCHER_PROP ,
50
- PANDINO_BUNDLE_IMPORTER_PROP ,
51
- DEPLOYMENT_ROOT_PROP ,
52
- } from ' @pandino/pandino-api' ;
42
+ import loaderConfiguration from ' @pandino/loader-configuration-dom' ;
53
43
54
44
const pandino = new Pandino ({
55
- [DEPLOYMENT_ROOT_PROP ]: location .href + ' deploy' ,
56
- [PANDINO_MANIFEST_FETCHER_PROP ]: {
57
- fetch : async (deploymentRoot : string , uri : string ) => (await fetch (deploymentRoot + ' /' + uri )).json (),
58
- },
59
- [PANDINO_BUNDLE_IMPORTER_PROP ]: {
60
- import : (deploymentRoot : string , activatorLocation : string , manifestLocation : string ) =>
61
- import (/* webpackIgnore: true */ deploymentRoot + ' /' + activatorLocation ),
62
- },
45
+ ... loaderConfiguration ,
63
46
});
64
47
65
48
await pandino .init ();
@@ -70,30 +53,19 @@ await pandino.getBundleContext().installBundle('some-bundle-manifest.json');
70
53
71
54
## Adding Pandino to a NodeJS (CJS) project
72
55
73
- Install Pandino via ` npm install --save @pandino/pandino ` .
56
+ Install Pandino via ` npm install --save @pandino/pandino @pandino/loader-configuration-nodejs ` .
74
57
75
58
Initialize it somewhere close in you applications own init logic, e.g.:
76
59
77
60
``` javascript
78
- const Pandino = require (" @pandino/pandino" ).default ;
79
- const path = require (" path" );
80
- const fs = require (" fs" );
61
+ const Pandino = require (" @pandino/pandino" );
62
+ const loaderConfiguration = require (" @pandino/loader-configuration-nodejs" );
81
63
82
64
const deploymentRoot = path .normalize (path .join (__dirname , ' deploy' ));
83
65
84
66
const pandino = new Pandino ({
85
- ' pandino.deployment.root' : deploymentRoot,
86
- ' pandino.bundle.importer' : {
87
- import : (deploymentRoot , activatorLocation ) => {
88
- return require (path .normalize (path .join (deploymentRoot, activatorLocation)));
89
- },
90
- },
91
- ' pandino.manifest.fetcher' : {
92
- fetch: async (deploymentRoot , uri ) => {
93
- const data = fs .readFileSync (path .normalize (path .join (deploymentRoot, uri)), { encoding: ' utf8' });
94
- return JSON .parse (data);
95
- },
96
- },
67
+ ... loaderConfiguration,
68
+ ' pandino.deployment.root' : deploymentRoot,
97
69
});
98
70
99
71
(async () => {
0 commit comments