# node-to-browser

> [![MIT license](https://img.shields.io/badge/license-MIT-98c611.svg)](https://github.com/cefsharp/CefSharp) [![pipeline status](https://gitlab.com/ncr-cc/node-to-browser/badges/master/pipeline.svg)](https://gitlab.com/ncr-cc/node-to-browser/pipelines) [![

Latest version **1.0.8** (published 2019-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-to-browser
pnpm add node-to-browser
yarn add node-to-browser
bun add node-to-browser
```

Provides the command `node-to-browser`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2019-04-16 |
| First published | 2019-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | tuxan |

## Links

- npm: https://www.npmjs.com/package/node-to-browser
- npm.io page: https://npm.io/package/node-to-browser

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2

## Recent versions

- 1.0.8 (latest) — 2019-04-16
- 1.0.7 — 2019-04-15
- 1.0.6 — 2019-04-15
- 1.0.5 — 2019-04-15
- 1.0.3 — 2019-04-15
- 1.0.2 — 2019-04-12
- 1.0.1 — 2019-04-11
- 1.0.0 — 2019-04-11

## README

# node-to-browser

[![MIT license](https://img.shields.io/badge/license-MIT-98c611.svg)](https://github.com/cefsharp/CefSharp)
[![pipeline status](https://gitlab.com/ncr-cc/node-to-browser/badges/master/pipeline.svg)](https://gitlab.com/ncr-cc/node-to-browser/pipelines)
[![coverage report](https://gitlab.com/ncr-cc/node-to-browser/badges/master/coverage.svg)](https://gitlab.com/ncr-cc/node-to-browser/commits/master)

Typescript transpile the import paths without based on any module resolver. So I wrote this node cli to convert all import path content found at *{jsPath}* folder to "*{root}+{current import path}+{extension}*". Also it is possible to replace content from import match using *{replace}* value.

The default configuration defined below:

```javascript
module.exports = {
    root: "/",
    jsPath: "./dist",
    extension: ".js",
    replace: {
        regex: /\/src\//mg,
        value: "/dist/"
    }
};
```

You must use this command after tsc execution like below:

```bash
tsc && node-to-browser
```

## Example

To convert all your import path from somethid like this *"@my/module/dist/util"* to *"<http://my.domain/js/node_modules/@my/module/dist/util.js">*, first you must create a configuration file at your project root named as *"node.to.browser.js"* with below content:

```javascript
module.exports = {
    root: "http://my.domain/js/node_modules/",
    jsPath: "./my/js/files", // specify your javascript folder content path
    // extension: ".js" // by default this is already ".js" value
    replace: {
        regex: /\/mysources\//mg,
        value: "/build/"
    }
};
```

So when *node-to-browser* is executed will find all import path candidates to convert to desired format. If some match is found then is modified and saved.

So if you have this import definition:

```javascript
import { Foo } from "@my/module/mysources/utils";
import { Foo } from "./common";
```

Before the *node-to-browser* execution yo will obtain this:

```javascript
import { Foo } from "http://my.domain/js/node_modules/@my/module/build/utils.js";
import { Foo } from "./common.js";
```

The *node-to-browser* command execution output will show you a detailed result.

---
_Source: https://npm.io/package/node-to-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
