An open API service indexing awesome lists of open source software.

https://github.com/bradymholt/ts-progressive-convert-namespace-modules

Example of progression conversion from TypeScript namespaces to modules
https://github.com/bradymholt/ts-progressive-convert-namespace-modules

Last synced: about 2 months ago
JSON representation

Example of progression conversion from TypeScript namespaces to modules

Awesome Lists containing this project

README

        

# ts-progressive-convert-namespace-modules

This repository demonstrates how to progressively convert a TypeScript library that uses global namespaces over to using modules.

The [src/entry.m.ts](https://github.com/bradymholt/ts-progressive-convert-namespace-modules/blob/master/src/entry.m.ts) file is the main [entry point](https://github.com/bradymholt/ts-progressive-convert-namespace-modules/blob/master/webpack.config.js#L6) in the webpack config. This file calls namespaced code and also imports
a module shim that runs namcespaced code. Progressively, namespaced code can be shimmied and then the namespaced code eventually folded directly into the modules.

The npm script "bundle" builds the namespace project which emits the outFile `dist/script.js`. This file is referenced in the [index.html](https://github.com/bradymholt/ts-progressive-convert-namespace-modules/blob/master/index.html) file before the webpack bundle is loaded.

## Usage

1. Run `npm install`
1. Run `npm run start`
1. Open http://localhost:5000 in a browser
1. Open devtools console and you should see:

```
bite bite bite bite
bark bark bark bark
ooh-ooh-ooh-eee-eee
```