-
Notifications
You must be signed in to change notification settings - Fork 28
/
build-fixup
executable file
·35 lines (32 loc) · 1.18 KB
/
build-fixup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# This creates package.json in each build type (cjs and mjs) that specifies what type of module resolution is used in
# in the rest of the subtree. Eq. for /cjs subfolder it specifies that CommonJS is used in that subfolder and so on.
# Source: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs",
"browser": {
"stream": false,
"fs": false,
"./utils/tar.js": "./utils/tar.browser.js",
"./utils/tar-writer.js": "./utils/tar-writer.browser.js",
"./utils/tar-uploader.js": "./utils/tar-uploader.browser.js",
"./utils/data.js": "./utils/data.browser.js",
"./utils/collection.node.js": "./utils/collection.browser.js"
}
}
!EOF
cat >dist/mjs/package.json <<!EOF
{
"type": "module",
"browser": {
"stream": false,
"fs": false,
"./utils/tar.js": "./utils/tar.browser.js",
"./utils/tar-writer.js": "./utils/tar-writer.browser.js",
"./utils/tar-uploader.js": "./utils/tar-uploader.browser.js",
"./utils/data.js": "./utils/data.browser.js",
"./utils/collection.node.js": "./utils/collection.browser.js"
}
}
!EOF