0.1.17 • Published 4 months ago

browser-bundler v0.1.17

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

BrowserBundler

Bundle React and TypeScript online without Node.js

Playground

https://mosya.dev/tools/react-ts

Screenshots

npm.io

Install

npm install browser-bundler

Example

import { browserBundle } from "browser-bundler";

const textarea = document.querySelector("#textarea") as HTMLTextAreaElement
const iframe = document.querySelector("#result") as HTMLIFrameElement

if (textarea && iframe) {
  textarea.value = `import React from "react";
import ReactDOM from "react-dom";

const App = () {
  return (<div>Hello World</div>
}

ReactDOM.render(<App />, document.getElementById("root"));`;

textarea.addEventListener("input", async () => {
  const code = textarea.value
  const { code: bundleCode } = await browserBundle(code)
  iframe.srcdoc = `
    <html>
      <head>
        <meta charset="utf-8">
      </head>
      <body>
        <div id="root"></div>
        <script type="module">
        ${bundleCode}
        </script>
      </body>
    </html>
  `
})
textarea.dispatchEvent(new Event("input"))

Relative Path

import { browserBundle } from "browser-bundler";

const code = `
import React from "react";
import ReactDOM from "react-dom";
import { Hello } from "./hello.tsx";

const App = () => {
  return (<div><Hello /></div>)
}

ReactDOM.render(<App />, document.getElementById("root"));
`

const result = await browserBundle(code, {
  files: {
    "./hello.tsx": `import React from "react";
    export const Hello = () => {
      return (<div>Hello World</div>)
    }`,
  }
})
0.1.16

4 months ago

0.1.17

4 months ago

0.1.14

1 year ago

0.1.15

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.2

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago