Mercurial > code > home > repos > streamed-graph
annotate rollup.config.js @ 78:ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
author | drewp@bigasterisk.com |
---|---|
date | Tue, 11 Feb 2020 22:55:24 -0800 |
parents | 0ba4bd0ba245 |
children | 0c188ed3bcd8 |
rev | line source |
---|---|
35 | 1 import builtins from "rollup-plugin-node-builtins"; |
47 | 2 import commonjs from "@rollup/plugin-commonjs"; |
48 | 3 import postcss from "rollup-plugin-postcss"; |
34 | 4 import resolve from "@rollup/plugin-node-resolve"; |
5 import typescript from "rollup-plugin-typescript2"; | |
6 | |
48 | 7 const workaround_jsonld_module_system_picker = "process = {version: '1.0.0'}"; |
8 const workaround_some_browser_detector = "global = window"; | |
9 const workaround_jsonld_expand_issue = { | |
10 namedExports: { | |
11 jsonld: ["expand"] // fixes "expand is not exported by node_modules/jsonld/lib/index.js" | |
12 } | |
13 }; | |
14 | |
78
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
15 const moduleIsntLocal = (id, parentId, isResolved) => { |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
16 console.log("check", id, !id.startsWith("./")); |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
17 if (isResolved || id == "src/index.ts") { |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
18 return false; |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
19 } |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
20 return !id.startsWith("./"); |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
21 }; |
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
22 |
48 | 23 export default [ |
24 { | |
35 | 25 input: "src/index.ts", |
26 output: { | |
50
1264ba9ffb10
make a full-element version for pages that want to try to use that
drewp@bigasterisk.com
parents:
48
diff
changeset
|
27 file: "build/lib.bundle.js", |
48 | 28 format: "esm", |
29 intro: `const ${workaround_some_browser_detector}, ${workaround_jsonld_module_system_picker};` | |
35 | 30 }, |
78
ea9c9db282d6
automate 'external' list, get all local code to appear in lib.bundle.js
drewp@bigasterisk.com
parents:
75
diff
changeset
|
31 external: moduleIsntLocal, |
35 | 32 plugins: [ |
48 | 33 builtins(), |
34 resolve({ | |
35 extensions: [".js", ".ts"], | |
36 browser: true, | |
37 }), | |
38 typescript(), | |
39 postcss({ | |
40 inject: false | |
41 }), | |
42 commonjs(workaround_jsonld_expand_issue) | |
35 | 43 ] |
48 | 44 }, |
45 { | |
46 input: "src/demo.ts", | |
47 output: { | |
48 file: "build/demo.js", | |
49 format: "esm", | |
50 intro: `const ${workaround_some_browser_detector}, ${workaround_jsonld_module_system_picker};` | |
51 }, | |
52 external: [], | |
53 plugins: [ | |
54 builtins(), | |
55 resolve({ | |
56 extensions: [".js", ".ts"], | |
57 browser: true | |
58 }), | |
59 typescript(), | |
60 postcss({ | |
61 inject: false | |
62 }), | |
63 commonjs(workaround_jsonld_expand_issue) | |
64 ] | |
65 } | |
66 ]; |