@atproto-labs/rollup-plugin-bundle-manifest 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @atproto-labs/rollup-plugin-bundle-manifest
2
2
 
3
- ## 0.0.1
3
+ ## 0.1.0
4
4
 
5
- ### Patch Changes
5
+ ### Minor Changes
6
6
 
7
- - [`e134c79a0`](https://github.com/bluesky-social/atproto/commit/e134c79a0ffb000b2cb36437815673fa6bda664b) Thanks [@devinivy](https://github.com/devinivy)! - Initial publish of experimental oauth packages to @atproto-labs
7
+ - [#2482](https://github.com/bluesky-social/atproto/pull/2482) [`a8d6c1123`](https://github.com/bluesky-social/atproto/commit/a8d6c112359f5c4c0cfbe2df63443ed275f2a646) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add OAuth provider capability & support for DPoP signed tokens
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # @atproto-labs/rollup-plugin-bundle-manifest
2
+
3
+ This Rollup plugin allows to generate a (JSON) manifest containing the output
4
+ files of a Rollup build. The manifest will look as follows:
5
+
6
+ ```json
7
+ {
8
+ "main.js": {
9
+ "type": "chunk",
10
+ "mime": "application/javascript",
11
+ "dynamicImports": [],
12
+ "isDynamicEntry": false,
13
+ "isEntry": true,
14
+ "isImplicitEntry": false,
15
+ "name": "main",
16
+ "sha256": "<sha256-hash>",
17
+ "data": "<base64-encoded-contents>"
18
+ },
19
+ "main.js.map": {
20
+ "type": "asset",
21
+ "mime": "application/json",
22
+ "sha256": "<sha256-hash>",
23
+ "data": "<base64-encoded-contents>"
24
+ },
25
+ "main.css": {
26
+ "type": "asset",
27
+ "mime": "text/css",
28
+ "sha256": "<sha256-hash>",
29
+ "data": "<base64-encoded-contents>"
30
+ }
31
+ // ... more entries as needed
32
+ }
33
+ ```
34
+
35
+ This manifest will typically be useful for a backend service that serves the
36
+ frontend assets, as it can be used to determine the correct `Content-Type` and
37
+ and file integrity (via the SHA-256 hash), without having to read the files
38
+ themselves.
39
+
40
+ ## Usage
41
+
42
+ ```js
43
+ // rollup.config.js
44
+
45
+ import bundleManifest from '@atproto-labs/rollup-plugin-bundle-manifest'
46
+
47
+ export default {
48
+ input: 'src/index.js',
49
+ output: {
50
+ dir: 'dist',
51
+ format: 'es',
52
+ },
53
+ plugins: [
54
+ bundleManifest({
55
+ name: 'bundle-manifest.json',
56
+
57
+ // Optional: should the asset data be embedded (as base64 string) in the manifest?
58
+ data: false,
59
+ }),
60
+ ],
61
+ }
62
+ ```
63
+
64
+ ## Options
65
+
66
+ - `name` (string): The name of the manifest file. Defaults to `bundle-manifest.json`.
67
+ - `data` (boolean): Whether to embed the asset data in the manifest. Defaults to `false`.
68
+
69
+ ## Example
70
+
71
+ ```js
72
+ const assetManifest = require('./dist/bundle-manifest.json')
73
+
74
+ const app = express()
75
+
76
+ app.use((req, res, next) => {
77
+ const asset = assetManifest[req.path.slice(1)]
78
+ if (!asset) return next()
79
+
80
+ res.setHeader('Content-Type', asset.mime)
81
+ res.setHeader('Content-Length', asset.data.length)
82
+
83
+ res.end(Buffer.from(asset.data, 'base64'))
84
+ })
85
+
86
+ app.use((req, res, next) => {
87
+ res.setHeader(
88
+ 'Content-Security-Policy',
89
+ buildCSP(assetManifest), // Not provided here
90
+ )
91
+
92
+ // Serve the index.html file
93
+ res.sendFile('index.html')
94
+ })
95
+ ```
96
+
97
+ ## License
98
+
99
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto-labs/rollup-plugin-bundle-manifest",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "license": "MIT",
5
5
  "description": "Library for generating a manifest of bundled files from a Rollup build",
6
6
  "keywords": [
@@ -12,7 +12,7 @@
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/bluesky-social/atproto",
15
- "directory": "packages/rollup-plugin-bundle-manifest"
15
+ "directory": "packages/internal/rollup-plugin-bundle-manifest"
16
16
  },
17
17
  "type": "commonjs",
18
18
  "main": "dist/index.js",
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": ["../../../tsconfig/node.json"],
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["src"]
8
+ }
package/tsconfig.json CHANGED
@@ -1,8 +1,4 @@
1
1
  {
2
- "extends": "../../tsconfig/node.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src"
6
- },
7
- "include": ["src"]
2
+ "include": [],
3
+ "references": [{ "path": "./tsconfig.build.json" }]
8
4
  }