@callstack/repack-dev-server 1.0.0-next.1 → 1.0.0-next.3
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 +18 -0
- package/dist/createServer.js +7 -3
- package/dist/createServer.js.map +1 -1
- package/dist/img/favicon.ico +0 -0
- package/dist/plugins/favicon/faviconPlugin.d.ts +3 -0
- package/dist/plugins/favicon/faviconPlugin.js +15 -0
- package/dist/plugins/favicon/faviconPlugin.js.map +1 -0
- package/dist/plugins/favicon/index.d.ts +1 -0
- package/dist/plugins/favicon/index.js +2 -0
- package/dist/plugins/favicon/index.js.map +1 -0
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @callstack/repack-dev-server
|
|
2
2
|
|
|
3
|
+
## 1.0.0-next.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#230](https://github.com/callstack/repack/pull/230) [`e6dc69d`](https://github.com/callstack/repack/commit/e6dc69d35f287af08d09944edd8e6d12f28484cf) Thanks [@jbinda](https://github.com/jbinda)! - Introduce `fastify-favicon` plugin to prevent server logger from emitting error log related to `GET 400 /favicon.ico` when requesting bundles via browser.
|
|
8
|
+
|
|
9
|
+
* [#239](https://github.com/callstack/repack/pull/239) [`6d65156`](https://github.com/callstack/repack/commit/6d65156366bc88edefdae7a3d0310ddbcdf48886) Thanks [@jbinda](https://github.com/jbinda)! - Expose favicon.ico in devserver
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#238](https://github.com/callstack/repack/pull/238) [`b913b89`](https://github.com/callstack/repack/commit/b913b8981334854cc13076af2a9c8a12bc465d1b) Thanks [@jbinda](https://github.com/jbinda)! - Add `archive` script in dev-server
|
|
14
|
+
|
|
15
|
+
## 1.0.0-next.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#200](https://github.com/callstack/repack/pull/200) [`c75cdc7`](https://github.com/callstack/repack/commit/c75cdc7a44351bb4702232e603031e2880f2839d) Thanks [@zamotany](https://github.com/zamotany)! - Prevent server logger from emitting log to API WS server before WS servers are created.
|
|
20
|
+
|
|
3
21
|
## 1.0.0-next.1
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/createServer.js
CHANGED
|
@@ -8,6 +8,7 @@ import compilerPlugin from "./plugins/compiler/index.js";
|
|
|
8
8
|
import devtoolsPlugin from "./plugins/devtools/index.js";
|
|
9
9
|
import apiPlugin from "./plugins/api/index.js";
|
|
10
10
|
import wssPlugin from "./plugins/wss/index.js";
|
|
11
|
+
import faviconPlugin from "./plugins/favicon/index.js";
|
|
11
12
|
import { Internal } from "./types.js";
|
|
12
13
|
import symbolicatePlugin from "./plugins/symbolicate/index.js";
|
|
13
14
|
/**
|
|
@@ -26,11 +27,11 @@ export async function createServer(config) {
|
|
|
26
27
|
level: 'trace',
|
|
27
28
|
stream: new Writable({
|
|
28
29
|
write: (chunk, _encoding, callback) => {
|
|
29
|
-
var _delegate;
|
|
30
|
+
var _delegate, _instance$wss;
|
|
30
31
|
|
|
31
32
|
const log = JSON.parse(chunk.toString());
|
|
32
33
|
(_delegate = delegate) === null || _delegate === void 0 ? void 0 : _delegate.logger.onMessage(log);
|
|
33
|
-
instance.wss.apiServer.send(log);
|
|
34
|
+
(_instance$wss = instance.wss) === null || _instance$wss === void 0 ? void 0 : _instance$wss.apiServer.send(log);
|
|
34
35
|
callback();
|
|
35
36
|
}
|
|
36
37
|
})
|
|
@@ -87,7 +88,10 @@ export async function createServer(config) {
|
|
|
87
88
|
root: debuggerAppPath,
|
|
88
89
|
prefix: '/debugger-ui',
|
|
89
90
|
prefixAvoidTrailingSlash: true
|
|
90
|
-
});
|
|
91
|
+
}); // below is to prevent showing `GET 400 /favicon.ico`
|
|
92
|
+
// errors in console when requesting the bundle via browser
|
|
93
|
+
|
|
94
|
+
await instance.register(faviconPlugin);
|
|
91
95
|
instance.addHook('onSend', async (request, reply, payload) => {
|
|
92
96
|
reply.header('X-Content-Type-Options', 'nosniff');
|
|
93
97
|
const [pathname] = request.url.split('?');
|
package/dist/createServer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.js","names":["Writable","Fastify","fastifySensible","fastifyStatic","debuggerAppPath","multipartPlugin","compilerPlugin","devtoolsPlugin","apiPlugin","wssPlugin","Internal","symbolicatePlugin","createServer","config","delegate","instance","logger","level","stream","write","chunk","_encoding","callback","log","JSON","parse","toString","onMessage","wss","apiServer","send","options","https","undefined","notifyBuildStart","platform","event","EventTypes","BuildStart","notifyBuildEnd","BuildEnd","broadcastToHmrClients","clientIds","hmrServer","broadcastToMessageClients","method","params","messageServer","broadcast","register","prefix","root","prefixAvoidTrailingSlash","addHook","request","reply","payload","header","pathname","url","split","endsWith","get","messages","getHello","getStatus","start","listen","port","host","stop","close"],"sources":["../src/createServer.ts"],"sourcesContent":["import { Writable } from 'stream';\nimport Fastify from 'fastify';\nimport fastifySensible from '@fastify/sensible';\nimport fastifyStatic from '@fastify/static';\nimport debuggerAppPath from '@callstack/repack-debugger-app';\nimport multipartPlugin from './plugins/multipart';\nimport compilerPlugin from './plugins/compiler';\nimport devtoolsPlugin from './plugins/devtools';\nimport apiPlugin from './plugins/api';\nimport wssPlugin from './plugins/wss';\nimport { Internal, Server } from './types';\nimport symbolicatePlugin from './plugins/symbolicate';\n\n/**\n * Create instance of development server, powered by Fastify.\n *\n * @param config Server configuration.\n * @returns `start` and `stop` functions as well as an underlying Fastify `instance`.\n */\nexport async function createServer(config: Server.Config) {\n let delegate: Server.Delegate;\n\n /** Fastify instance powering the development server. */\n const instance = Fastify({\n logger: {\n level: 'trace',\n stream: new Writable({\n write: (chunk, _encoding, callback) => {\n const log = JSON.parse(chunk.toString());\n delegate?.logger.onMessage(log);\n instance.wss
|
|
1
|
+
{"version":3,"file":"createServer.js","names":["Writable","Fastify","fastifySensible","fastifyStatic","debuggerAppPath","multipartPlugin","compilerPlugin","devtoolsPlugin","apiPlugin","wssPlugin","faviconPlugin","Internal","symbolicatePlugin","createServer","config","delegate","instance","logger","level","stream","write","chunk","_encoding","callback","log","JSON","parse","toString","onMessage","wss","apiServer","send","options","https","undefined","notifyBuildStart","platform","event","EventTypes","BuildStart","notifyBuildEnd","BuildEnd","broadcastToHmrClients","clientIds","hmrServer","broadcastToMessageClients","method","params","messageServer","broadcast","register","prefix","root","prefixAvoidTrailingSlash","addHook","request","reply","payload","header","pathname","url","split","endsWith","get","messages","getHello","getStatus","start","listen","port","host","stop","close"],"sources":["../src/createServer.ts"],"sourcesContent":["import { Writable } from 'stream';\nimport Fastify from 'fastify';\nimport fastifySensible from '@fastify/sensible';\nimport fastifyStatic from '@fastify/static';\nimport debuggerAppPath from '@callstack/repack-debugger-app';\nimport multipartPlugin from './plugins/multipart';\nimport compilerPlugin from './plugins/compiler';\nimport devtoolsPlugin from './plugins/devtools';\nimport apiPlugin from './plugins/api';\nimport wssPlugin from './plugins/wss';\nimport faviconPlugin from './plugins/favicon';\nimport { Internal, Server } from './types';\nimport symbolicatePlugin from './plugins/symbolicate';\n\n/**\n * Create instance of development server, powered by Fastify.\n *\n * @param config Server configuration.\n * @returns `start` and `stop` functions as well as an underlying Fastify `instance`.\n */\nexport async function createServer(config: Server.Config) {\n let delegate: Server.Delegate;\n\n /** Fastify instance powering the development server. */\n const instance = Fastify({\n logger: {\n level: 'trace',\n stream: new Writable({\n write: (chunk, _encoding, callback) => {\n const log = JSON.parse(chunk.toString());\n delegate?.logger.onMessage(log);\n instance.wss?.apiServer.send(log);\n callback();\n },\n }),\n },\n ...(config.options.https ? { https: config.options.https } : undefined),\n });\n\n delegate = config.delegate({\n log: instance.log,\n notifyBuildStart: (platform) => {\n instance.wss.apiServer.send({\n event: Internal.EventTypes.BuildStart,\n platform,\n });\n },\n notifyBuildEnd: (platform) => {\n instance.wss.apiServer.send({\n event: Internal.EventTypes.BuildEnd,\n platform,\n });\n },\n broadcastToHmrClients: (event, platform, clientIds) => {\n instance.wss.hmrServer.send(event, platform, clientIds);\n },\n broadcastToMessageClients: ({ method, params }) => {\n instance.wss.messageServer.broadcast(method, params);\n },\n });\n\n // Register plugins\n await instance.register(fastifySensible);\n await instance.register(wssPlugin, {\n options: config.options,\n delegate,\n });\n await instance.register(multipartPlugin);\n await instance.register(apiPlugin, {\n delegate,\n prefix: '/api',\n });\n await instance.register(compilerPlugin, {\n delegate,\n });\n await instance.register(symbolicatePlugin, {\n delegate,\n });\n await instance.register(devtoolsPlugin, {\n options: config.options,\n });\n\n await instance.register(fastifyStatic, {\n root: debuggerAppPath,\n prefix: '/debugger-ui',\n prefixAvoidTrailingSlash: true,\n });\n // below is to prevent showing `GET 400 /favicon.ico`\n // errors in console when requesting the bundle via browser\n await instance.register(faviconPlugin);\n\n instance.addHook('onSend', async (request, reply, payload) => {\n reply.header('X-Content-Type-Options', 'nosniff');\n\n const [pathname] = request.url.split('?');\n if (pathname.endsWith('.map')) {\n reply.header('Access-Control-Allow-Origin', 'devtools://devtools');\n }\n\n return payload;\n });\n\n // Register routes\n instance.get('/', async () => delegate.messages.getHello());\n instance.get('/status', async () => delegate.messages.getStatus());\n\n /** Start the development server. */\n async function start() {\n await instance.listen(config.options.port, config.options.host);\n }\n\n /** Stop the development server. */\n async function stop() {\n await instance.close();\n }\n\n return {\n start,\n stop,\n instance,\n };\n}\n"],"mappings":"AAAA,SAASA,QAAT,QAAyB,QAAzB;AACA,OAAOC,OAAP,MAAoB,SAApB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,gCAA5B;OACOC,e;OACAC,c;OACAC,c;OACAC,S;OACAC,S;OACAC,a;SACEC,Q;OACFC,iB;AAEP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,eAAeC,YAAf,CAA4BC,MAA5B,EAAmD;EACxD,IAAIC,QAAJ;E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C5DD,KAAK,CAACE,MAAN,CAAa,wBAAb,EAAuC,SAAvC;IAEA,MAAM,CAACC,QAAD,IAAaJ,OAAO,CAACK,GAAR,CAAYC,KAAZ,CAAkB,GAAlB,CAAnB;;IACA,IAAIF,QAAQ,CAACG,QAAT,CAAkB,MAAlB,CAAJ,EAA+B;MAC7BN,KAAK,CAACE,MAAN,CAAa,6BAAb,EAA4C,qBAA5C;IACD;;IAED,OAAOD,OAAP;EACD,CATD,EAvEwD,CAkFxD;;EACAzC,QAAQ,CAAC+C,GAAT,CAAa,GAAb,EAAkB,YAAYhD,QAAQ,CAACiD,QAAT,CAAkBC,QAAlB,EAA9B;EACAjD,QAAQ,CAAC+C,GAAT,CAAa,SAAb,EAAwB,YAAYhD,QAAQ,CAACiD,QAAT,CAAkBE,SAAlB,EAApC;EAEA;;EACA,eAAeC,KAAf,GAAuB;IACrB,MAAMnD,QAAQ,CAACoD,MAAT,CAAgBtD,MAAM,CAACkB,OAAP,CAAeqC,IAA/B,EAAqCvD,MAAM,CAACkB,OAAP,CAAesC,IAApD,CAAN;EACD;EAED;;;EACA,eAAeC,IAAf,GAAsB;IACpB,MAAMvD,QAAQ,CAACwD,KAAT,EAAN;EACD;;EAED,OAAO;IACLL,KADK;IAELI,IAFK;IAGLvD;EAHK,CAAP;AAKD"}
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import fastifyFavicon from 'fastify-favicon';
|
|
2
|
+
import fastifyPlugin from 'fastify-plugin'; // @ts-ignore
|
|
3
|
+
|
|
4
|
+
const pathToImg = new URL('../../img', import.meta.url).pathname;
|
|
5
|
+
|
|
6
|
+
async function faviconPlugin(instance) {
|
|
7
|
+
instance.register(fastifyFavicon, {
|
|
8
|
+
path: pathToImg
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default fastifyPlugin(faviconPlugin, {
|
|
13
|
+
name: 'favicon-plugin'
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=faviconPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"faviconPlugin.js","names":["fastifyFavicon","fastifyPlugin","pathToImg","URL","import","meta","url","pathname","faviconPlugin","instance","register","path","name"],"sources":["../../../src/plugins/favicon/faviconPlugin.ts"],"sourcesContent":["import fastifyFavicon from 'fastify-favicon';\nimport type { FastifyInstance } from 'fastify';\nimport fastifyPlugin from 'fastify-plugin';\n\n// @ts-ignore\nconst pathToImg = new URL('../../img', import.meta.url).pathname;\n\nasync function faviconPlugin(instance: FastifyInstance) {\n instance.register(fastifyFavicon, { path: pathToImg });\n}\n\nexport default fastifyPlugin(faviconPlugin, {\n name: 'favicon-plugin',\n});\n"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,iBAA3B;AAEA,OAAOC,aAAP,MAA0B,gBAA1B,C,CAEA;;AACA,MAAMC,SAAS,GAAG,IAAIC,GAAJ,CAAQ,WAAR,EAAqBC,MAAM,CAACC,IAAP,CAAYC,GAAjC,EAAsCC,QAAxD;;AAEA,eAAeC,aAAf,CAA6BC,QAA7B,EAAwD;EACtDA,QAAQ,CAACC,QAAT,CAAkBV,cAAlB,EAAkC;IAAEW,IAAI,EAAET;EAAR,CAAlC;AACD;;AAED,eAAeD,aAAa,CAACO,aAAD,EAAgB;EAC1CI,IAAI,EAAE;AADoC,CAAhB,CAA5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './faviconPlugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default"],"sources":["../../../src/plugins/favicon/index.ts"],"sourcesContent":["export { default } from './faviconPlugin';\n"],"mappings":"SAASA,O"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@callstack/repack-dev-server",
|
|
3
3
|
"description": "A bundler-agnostic development server for React Native applications as part of @callstack/repack.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0.0-next.
|
|
5
|
+
"version": "1.0.0-next.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -34,14 +34,15 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build:js": "babel src --out-dir dist --extensions \".js,.cjs,.ts\" --source-maps --ignore \"**/__tests__/**\" --delete-dir-on-start",
|
|
37
|
+
"build:js": "babel src --out-dir dist --extensions \".js,.cjs,.ts\" --source-maps --ignore \"**/__tests__/**\" --delete-dir-on-start --copy-files",
|
|
38
38
|
"build:js:watch": "yarn build:js --watch",
|
|
39
39
|
"build:ts": "tsc --emitDeclarationOnly",
|
|
40
40
|
"build:ts:watch": "yarn build:ts --watch --preserveWatchOutput",
|
|
41
41
|
"build": "yarn build:js && yarn build:ts",
|
|
42
42
|
"docs": "typedoc",
|
|
43
43
|
"typecheck": "tsc --noEmit",
|
|
44
|
-
"lint": "eslint --ext \".js,.ts\" src"
|
|
44
|
+
"lint": "eslint --ext \".js,.ts\" src",
|
|
45
|
+
"archive": "yarn build && yarn pack --out repack-dev-server-%v-$(git log -1 --format=\"%h\").tgz"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"@babel/code-frame": "^7.16.7",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@fastify/sensible": "^4.1.0",
|
|
50
51
|
"@fastify/static": "^5.0.2",
|
|
51
52
|
"fastify": "^3.29.0",
|
|
53
|
+
"fastify-favicon": "^3.2.0",
|
|
52
54
|
"fastify-plugin": "^3.0.1",
|
|
53
55
|
"metro-inspector-proxy": "^0.71.0",
|
|
54
56
|
"open": "^8.4.0",
|