bun-dev-server 0.0.1

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.
@@ -0,0 +1,36 @@
1
+ {
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ "version": "0.2.0",
6
+ "configurations": [
7
+ {
8
+ "type": "bun",
9
+ "internalConsoleOptions": "neverOpen",
10
+ "request": "launch",
11
+ "name": "Debug File",
12
+ "program": "${file}",
13
+ "cwd": "${workspaceFolder}",
14
+ "stopOnEntry": false,
15
+ "watchMode": false
16
+ },
17
+ {
18
+ "type": "bun",
19
+ "internalConsoleOptions": "neverOpen",
20
+ "request": "launch",
21
+ "name": "Run File",
22
+ "program": "${file}",
23
+ "cwd": "${workspaceFolder}",
24
+ "noDebug": true,
25
+ "watchMode": false
26
+ },
27
+ {
28
+ "type": "bun",
29
+ "internalConsoleOptions": "neverOpen",
30
+ "request": "attach",
31
+ "name": "Attach Bun",
32
+ "url": "ws://localhost:6499/",
33
+ "stopOnEntry": false
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "[html]": {
3
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
4
+ },
5
+ "[typescript]": {
6
+ "editor.defaultFormatter": "vscode.typescript-language-features"
7
+ },
8
+ "editor.defaultFormatter": null,
9
+ "html.format.enable": true,
10
+ "js-beautify.break_chained_methods": true,
11
+ "js-beautify.indent_inner_html": true,
12
+ "js-beautify.brace_style": "expand",
13
+ "typescript.tsdk": "node_modules\\typescript\\lib"
14
+
15
+ }
@@ -0,0 +1,5 @@
1
+ declare module "*.ejs" {
2
+ const template: string;
3
+ export default template;
4
+ }
5
+ // export {};
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SPWizard01
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Bun Dev Server
2
+
3
+ ```
4
+ //devserver.ts
5
+ import {startBunDevServer} from "bun-dev-server"
6
+
7
+ startBunDevServer({
8
+ buildConfig: {
9
+ entrypoints: ["./src/app.ts"],
10
+ outdir: "dist",
11
+ splitting: true,
12
+ naming: {
13
+ asset: "assets/[name]-[hash].[ext]",
14
+ chunk: "chunks/[name]-[hash].[ext]",
15
+ }
16
+ },
17
+ cleanServePath: true,
18
+ port: 4567,
19
+ enableTypeScriptWatch: true,
20
+ watchDir: "./src",
21
+ })
22
+ ```
23
+
24
+ ```
25
+ bun run devserver.ts
26
+ ```
package/bun.lockb ADDED
Binary file
@@ -0,0 +1,47 @@
1
+ import { type BunDevServerSocketConfig } from "./bunServeConfig";
2
+
3
+ function hotReload() {
4
+ const hmrSock = new WebSocket("[REPLACE_ENDPOINT]");
5
+ hmrSock.addEventListener("error", (err) => {
6
+ console.error("HMR ERROR", err);
7
+ })
8
+ hmrSock.addEventListener("message", (msg) => {
9
+ let parsed = msg.data;
10
+ try {
11
+ parsed = JSON.parse(msg.data);
12
+ } catch (e) { }
13
+ if (parsed?.type === "message") {
14
+ console.log(parsed.message);
15
+ return;
16
+ }
17
+ if (parsed?.type === "output") {
18
+ console.table(parsed.message);
19
+ return;
20
+ }
21
+ if (parsed?.type === "reload") {
22
+ window.location.reload();
23
+ return;
24
+ }
25
+ if (parsed?.type === "error") {
26
+ console.error(parsed.message);
27
+ let newDiv = window.document.getElementById("bun-hmr-error")
28
+ const divExists = !!newDiv;
29
+ if (!newDiv) {
30
+ newDiv = window.document.createElement("div");
31
+ }
32
+ newDiv.id = "bun-hmr-error";
33
+ newDiv.innerText += parsed.message;
34
+ if (!divExists) {
35
+
36
+ window.document.body.appendChild(newDiv);
37
+ }
38
+ return;
39
+ }
40
+ });
41
+ }
42
+
43
+ export function bunHotReload(bunServerConfig: BunDevServerSocketConfig) {
44
+ const endPath = bunServerConfig.websocketPath.startsWith("/") ? bunServerConfig.websocketPath : `/${bunServerConfig.websocketPath}`;
45
+ const path = `${(bunServerConfig.tls ? "wss" : "ws")}://localhost:${bunServerConfig.port}${endPath}`;
46
+ return hotReload.toString().replace("[REPLACE_ENDPOINT]", path);
47
+ }
@@ -0,0 +1,29 @@
1
+ import { type BunPlugin } from "bun";
2
+ import { bunHotReload } from "./bunClientHmr";
3
+ import { readFile } from "fs/promises";
4
+ import { type BunDevServerSocketConfig } from "./bunServeConfig";
5
+ export function getBunHMRPlugin(config: BunDevServerSocketConfig) {
6
+ const bunHMRPlugin: BunPlugin = {
7
+ name: "hmr",
8
+ target: "browser",
9
+ setup(build) {
10
+ let hmrAdded = false;
11
+ build.onLoad({ filter: /\.m?tsx?/ }, async (args) => {
12
+ const contents = await readFile(args.path, { encoding: "utf-8" });
13
+ if (!hmrAdded) {
14
+ hmrAdded = true;
15
+ return { contents: `import "bun-hot-reload"\n` + contents, loader: "ts" };
16
+ }
17
+ return { contents, loader: "ts" };
18
+ });
19
+ build.onLoad({ filter: /./, namespace: "bun-hot-reload" }, async (args) => {
20
+
21
+ return { contents: `(${bunHotReload(config)})()\n`, loader: "ts" };
22
+ });
23
+ build.onResolve({ filter: /^bun-hot-reload$/ }, (args) => {
24
+ return { path: args.path, namespace: "bun-hot-reload" };
25
+ })
26
+ },
27
+ }
28
+ return bunHMRPlugin;
29
+ }
@@ -0,0 +1,23 @@
1
+ import { type BuildConfig, type TLSOptions } from "bun";
2
+
3
+ export interface BunDevServerConfig extends Partial<BunDevServerSocketConfig> {
4
+ port: number;
5
+ buildConfig: BuildConfig;
6
+ watchDir?: string;
7
+ enableTypeScriptWatch?: boolean;
8
+ /**
9
+ * The path to the directory to serve files from.
10
+ * Takes precedence over `buildConfig.outdir`.
11
+ * Defaults to "dist".
12
+ */
13
+ servePath?: string;
14
+ cleanServePath?: boolean;
15
+ serveOutputEjs?: string;
16
+ serveOutputHtml?: string;
17
+ }
18
+
19
+ export interface BunDevServerSocketConfig {
20
+ port: number;
21
+ tls?: TLSOptions;
22
+ websocketPath: string;
23
+ }
@@ -0,0 +1,74 @@
1
+ import { $, type Server, type Subprocess, resolve } from "bun";
2
+ export async function startTSWatcher(server: Server, watchDir: URL) {
3
+ let dstcwd: string | undefined;
4
+ if (watchDir) {
5
+ dstcwd = process.platform === "win32" ? watchDir.pathname.substring(1) : watchDir.pathname;
6
+ }
7
+
8
+ console.log("Starting TypeScript watcher in", dstcwd);
9
+ // var tscResolved = await resolve("tsc", import.meta.dir);
10
+ //const tsc = await $`bun run ${tscResolved} --noEmit --watch ${dstcwd}/*.ts`.quiet().arrayBuffer();
11
+ let tsc: Subprocess | undefined;
12
+ try {
13
+ tsc = Bun.spawn(["tsc", "--watch", "--project", `${import.meta.dir}/tsconfig.json`], { stdout: "pipe", stderr: "pipe" });
14
+ } catch (e) {
15
+ console.error("TSC not found have you installed it globally?");
16
+ return;
17
+ }
18
+ for await (const chunk of tsc.stdout as any) {
19
+ const strVal = new TextDecoder().decode(chunk);
20
+ const isError = /Found [1-9]\d* errors?\./.test(strVal);
21
+ const isNoError = /Found 0 errors?\./.test(strVal);
22
+ const isErrorLine = /error TS/.test(strVal);
23
+ let msgType = "message";
24
+ if (isError || isErrorLine) {
25
+ console.error(strVal);
26
+ msgType = "error";
27
+ }
28
+ else if (isNoError) {
29
+ console.log("\x1b[32m", strVal, "\x1b[0m");
30
+ }
31
+ else {
32
+ console.log(strVal);
33
+ }
34
+ server.publish("message", JSON.stringify({ type: msgType, message: strVal }));
35
+ if (isNoError) {
36
+ server.publish("message", JSON.stringify({ type: "reload", message: "" }));
37
+ }
38
+ }
39
+ // if (!Bun.stdout.readable.locked) {
40
+ // const tscErrorReader = Bun.stdout.readable.getReader();
41
+
42
+ // // tsc.stdout.pipeThrough(new TextDecoderStream());
43
+ // tscErrorReader.read().then(async function processResult(stdoutresult) {
44
+ // if (stdoutresult.value) {
45
+ // const strVal = Buffer.from(stdoutresult.value).toString();
46
+ // const isError = /Found [1-9]\d* errors?\./.test(strVal);
47
+ // const isNoError = /Found 0 errors?\./.test(strVal);
48
+ // const isErrorLine = /error TS/.test(strVal);
49
+ // let msgType = "message";
50
+ // if (isError || isErrorLine) {
51
+ // console.error(new Error(strVal));
52
+ // msgType = "error";
53
+ // //await Bun.write(Bun.stderr, stdoutresult.value);
54
+ // } else {
55
+ // console.log(strVal);
56
+ // }
57
+ // server.publish("message", JSON.stringify({ type: msgType, message: strVal }));
58
+ // if(isNoError) {
59
+ // server.publish("message", JSON.stringify({ type: "reload", message: "" }));
60
+ // }
61
+ // // const resVal = result.value;
62
+ // // const strVal = Buffer.from(result.value).toString();
63
+ // // await Bun.write(Bun.stdout, stdoutresult.value);
64
+ // // const result = strVal.indexOf("error") !== -1 ? new Error(strVal) : strVal;
65
+ // // console.log(Bun.inspect(result, {colors: true}));
66
+ // // Bun.stdout.writer().write();
67
+ // }
68
+ // if (stdoutresult.done) {
69
+ // return;
70
+ // }
71
+ // tscErrorReader.read().then(processResult);
72
+ // });
73
+ // }
74
+ }
package/index.ts ADDED
@@ -0,0 +1,196 @@
1
+ /// <reference path="./@types/serve.ts" />
2
+ import { render } from "ejs";
3
+ import Bun, { $, ShellError } from "bun";
4
+ import serveTemplate from "./serveOutputTemplate.ejs" with { type: "text" };
5
+ import indexTemplate from "./indexHTMLTemplate.ejs" with { type: "text" };
6
+ import { watch, readdir, exists, readFile } from "fs/promises";
7
+ import { type FileChangeInfo } from "fs/promises";
8
+ import { startTSWatcher } from "./bunTSWatcher";
9
+ import { getBunHMRPlugin } from "./bunHmrPlugin";
10
+ import { type BunDevServerConfig } from "./bunServeConfig";
11
+
12
+
13
+
14
+ export async function startBunDevServer(serverConfig: BunDevServerConfig) {
15
+ const defaultConfig = {
16
+ port: 3000,
17
+ websocketPath: "/hmr-ws",
18
+ serveOutputEjs: serveTemplate,
19
+ serveOutputHtml: indexTemplate
20
+ }
21
+ const finalConfig = { ...defaultConfig, ...serverConfig };
22
+ const serveDestination = finalConfig.buildConfig.outdir ?? finalConfig.servePath ?? "dist";
23
+ const bunDestinationPath = Bun.pathToFileURL(serveDestination);
24
+ const dst = process.platform === "win32" ? bunDestinationPath.pathname.substring(1) : bunDestinationPath.pathname;
25
+ try {
26
+ await readdir(dst)
27
+ } catch (e) {
28
+ if ((e as ErrnoException).code === "ENOENT") {
29
+ console.log("Directory not found, creating it...");
30
+ await $`mkdir ${dst}`;
31
+ } else {
32
+ throw e;
33
+ }
34
+ }
35
+ const buildCfg: Bun.BuildConfig = {
36
+ ...serverConfig.buildConfig,
37
+ outdir: dst,
38
+ plugins: [...serverConfig.buildConfig.plugins ?? [], getBunHMRPlugin({ port: finalConfig.port, tls: finalConfig.tls, websocketPath: finalConfig.websocketPath })]
39
+ }
40
+
41
+ if (serverConfig.cleanServePath) {
42
+ await cleanDirectory(dst);
43
+ }
44
+
45
+ const bunServer = Bun.serve({
46
+ port: finalConfig.port,
47
+ development: true,
48
+ tls: finalConfig.tls,
49
+ async fetch(req, server) {
50
+ if (req.url.toLowerCase().endsWith("/favicon.ico")) {
51
+ return new Response("", { status: 404 });
52
+ }
53
+ if (req.url.toLowerCase().endsWith(finalConfig.websocketPath)) {
54
+ if (server.upgrade(req)) {
55
+ return;
56
+ }
57
+ }
58
+ const url = new URL(req.url);
59
+ const requestPath = url.pathname;
60
+ const objThere = await exists(dst + requestPath);
61
+ let isDirectory = false;
62
+ if (objThere) {
63
+ try {
64
+ await readFile(dst + requestPath);
65
+ } catch (e) {
66
+ if ((e as ErrnoException).code === "EISDIR") {
67
+ isDirectory = true;
68
+ } else {
69
+ throw e;
70
+ }
71
+ }
72
+ }
73
+
74
+ if (!isDirectory) {
75
+ const fl = Bun.file(dst + requestPath);
76
+ return new Response(fl);
77
+ }
78
+ try {
79
+ const allEntries = await readdir(dst + requestPath, {
80
+ withFileTypes: true,
81
+ });
82
+ const dirs = allEntries
83
+ .filter((entry) => entry.isDirectory())
84
+ .map((entry) => {
85
+ return {
86
+ requestPath: requestPath === "/" ? "" : requestPath,
87
+ name: entry.name,
88
+ };
89
+ });
90
+ const files = allEntries
91
+ .filter((entry) => entry.isFile())
92
+ .map((entry) => {
93
+ return {
94
+ requestPath: requestPath === "/" ? "" : requestPath,
95
+ name: entry.name,
96
+ };
97
+ });
98
+ const rnd = render(finalConfig.serveOutputEjs, { dirs, files });
99
+ return new Response(rnd, { headers: { "Content-Type": "text/html" } });
100
+ } catch {
101
+ return new Response("Not Found", { status: 404 });
102
+ }
103
+ },
104
+
105
+
106
+ websocket: {
107
+ open(ws) {
108
+ ws.subscribe("message");
109
+ },
110
+ message(ws, message) {
111
+ },
112
+ sendPings: true
113
+ }
114
+ });
115
+
116
+
117
+ const output = await Bun.build(buildCfg);
118
+ publishOutputLogs(output, { filename: "Initial", eventType: "change" });
119
+ publishIndexHTML(output, { filename: "Initial", eventType: "change" });
120
+ // $`tsc --watch`.then((tsc) => {
121
+ // console.log("ASDASD");
122
+ // });
123
+
124
+ if (finalConfig.enableTypeScriptWatch) {
125
+ if(!finalConfig.watchDir) {
126
+ throw new Error("watchDir must be set to enable TypeScript watch");
127
+ }
128
+ const watchDir = Bun.pathToFileURL(finalConfig.watchDir);
129
+ startTSWatcher(bunServer, watchDir);
130
+ }
131
+ const watcher = watch("./src", { recursive: true });
132
+ for await (const event of watcher) {
133
+ if (finalConfig.cleanServePath) {
134
+ await cleanDirectory(dst);
135
+ }
136
+ const output = await Bun.build(buildCfg);
137
+ publishOutputLogs(output, event);
138
+ publishIndexHTML(output, event);
139
+ }
140
+
141
+ function publishOutputLogs(output: Bun.BuildOutput, event: FileChangeInfo<string>) {
142
+ output.logs.forEach(console.log);
143
+ bunServer.publish("message", JSON.stringify({ type: "message", message: `[Bun HMR] ${event.filename} ${event.eventType}` }));
144
+ const outTable = output.outputs.filter(o => o.kind !== "sourcemap").map(o => {
145
+ const a = Bun.pathToFileURL(o.path);
146
+ const fileName = a.href.substring(a.href.lastIndexOf("/") + 1);
147
+ return {
148
+ name: fileName,
149
+ path: o.path,
150
+ size: convertBytes(o.size)
151
+ };
152
+ });
153
+ console.table(outTable);
154
+ bunServer.publish("message", JSON.stringify({ type: "output", message: outTable }));
155
+ }
156
+
157
+ function publishIndexHTML(output: Bun.BuildOutput, event: FileChangeInfo<string>) {
158
+ const ep = output.outputs.find(o => o.kind === "entry-point");
159
+ if (ep) {
160
+ const basePathUrl = Bun.pathToFileURL(dst);
161
+ const epUrl = Bun.pathToFileURL(ep.path);
162
+ const hashedImport = `${epUrl.href.replace(basePathUrl.href, "")}?${ep.hash}`;
163
+ Bun.write(dst + "/index.html", render(finalConfig.serveOutputHtml, { hashedImport }));
164
+ }
165
+ }
166
+
167
+ }
168
+
169
+ async function cleanDirectory(dst: string) {
170
+ const { stderr, exitCode } = await $`rm -rf ${dst}/*`.nothrow();
171
+ if (exitCode !== 0) {
172
+ if (stderr.indexOf("no matches found") > -1) {
173
+ console.log("Directory is empty");
174
+ } else {
175
+ throw stderr;
176
+ }
177
+ }
178
+ }
179
+
180
+ function convertBytes(bytes: number) {
181
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"]
182
+
183
+ if (bytes == 0) {
184
+ return "n/a"
185
+ }
186
+ const floored = Math.floor(Math.log(bytes) / Math.log(1024));
187
+ // console.log(floored);
188
+ // console.log(parseInt(`${floored}`));
189
+ const i = floored;
190
+
191
+ if (i == 0) {
192
+ return bytes + " " + sizes[i]
193
+ }
194
+
195
+ return (bytes / Math.pow(1024, i)).toFixed(1) + " " + sizes[i]
196
+ }
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Bun HTML File</title>
7
+ <script type="module" src="<%= hashedImport %>"></script>
8
+ </head>
9
+
10
+ <body>
11
+ <div id="app"></div>
12
+ </body>
13
+ </html>
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "bun-dev-server",
3
+ "description": "A simple development server for TypeScript projects using Bun",
4
+ "author": "SPWizard01 (https://github.com/SPWizard01/bun-dev-server)",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/SPWizard01/bun-dev-server"
8
+ },
9
+ "version": "0.0.1",
10
+ "module": "index.ts",
11
+ "type": "module",
12
+ "scripts": {
13
+ "serve": "bun --hot ./serve.ts"
14
+ },
15
+ "devDependencies": {
16
+ "@types/bun": "latest",
17
+ "@types/ejs": "^3.1.5"
18
+ },
19
+ "peerDependencies": {
20
+ "typescript": "^5.5.4"
21
+ },
22
+ "dependencies": {
23
+ "ejs": "^3.1.10"
24
+ }
25
+ }
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Document</title>
8
+ </head>
9
+
10
+ <body>
11
+ <a href="../">..</a>
12
+ <% dirs.forEach(element => { %> <br /><a href=".<%= element.requestPath %>/<%= element.name %>"><%= element.name %></a> <% }) %>
13
+ <% files.forEach(element => { %> <br /><a href=".<%= element.requestPath %>/<%= element.name %>"><%= element.name %></a> <% }) %>
14
+ </body>
15
+
16
+ </html>
package/test/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # test
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run app.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.1.27. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
package/test/bun.lockb ADDED
Binary file
package/test/bunrun.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { startBunDevServer } from "../index"
2
+
3
+ startBunDevServer({
4
+ buildConfig: {
5
+ entrypoints: ["./src/app.ts"],
6
+ outdir: "dist",
7
+ splitting: true,
8
+ naming: {
9
+ asset: "assets/[name]-[hash].[ext]",
10
+ chunk: "chunks/[name]-[hash].[ext]",
11
+ }
12
+ },
13
+ cleanServePath: true,
14
+ port: 4567,
15
+ enableTypeScriptWatch: true,
16
+ watchDir: "./src",
17
+ })
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "test",
3
+ "module": "app.ts",
4
+ "type": "module",
5
+ "devDependencies": {
6
+ "@types/bun": "^1.1.8"
7
+ },
8
+ "peerDependencies": {
9
+ "typescript": "^5.0.0"
10
+ },
11
+ "dependencies": {
12
+ "@pnp/queryable": "^4.4.0",
13
+ "@pnp/sp": "^4.4.0",
14
+ "bun": "^1.1.27"
15
+ }
16
+ }
@@ -0,0 +1,4 @@
1
+ declare module "*.svg" {
2
+ const template: string;
3
+ export default template;
4
+ }
@@ -0,0 +1,10 @@
1
+ import { bla } from "./something"
2
+
3
+ bla();
4
+ const app = window.document.querySelector("#app");
5
+ if(app) {
6
+ app.textContent = "Hello World";
7
+ }
8
+ const {bla2} = await import("./services/someservice");
9
+ bla2();
10
+
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="-100 -100 200 200">
2
+ <polygon points="0,0 80,120 -80,120" fill="#234236" />
3
+ <polygon points="0,-40 60,60 -60,60" fill="#0C5C4C" />
4
+ <polygon points="0,-80 40,0 -40,0" fill="#38755B" />
5
+ <rect x="-20" y="120" width="40" height="30" fill="brown" />
6
+ </svg>
@@ -0,0 +1,7 @@
1
+ import somesvg from "../assets/something.svg"
2
+ import { SPBrowser, spfi } from "@pnp/sp"
3
+ import { BearerToken } from "@pnp/queryable"
4
+ export async function bla2() {
5
+ console.log(somesvg);
6
+ spfi("s");
7
+ };
@@ -0,0 +1,3 @@
1
+ export function bla() {
2
+ console.log("GGGFsss");
3
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "auto",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "preserveWatchOutput": true,
22
+ // Some stricter flags (disabled by default)
23
+ "noUnusedLocals": false,
24
+ "noUnusedParameters": false,
25
+ "noPropertyAccessFromIndexSignature": false
26
+ }
27
+ }