Reputation: 85
At the moment, our organization is developing a JavaScript library for use with one of our products. Currently, this is developed through the following steps:
/// <reference>
tags to determine dependencies--out
flag) from _references.ts
(a two step process, for internal and public APIs), concatenate and minify everything into a single js file.d.ts
file for the public APIWe've been looking at updating our codebase, and we're looking at the more recent updates to TypeScript's features, specifically, moving towards using a single tsconfig.json
, and the use of ES6 modules. I admit I don't have the most comprehensive knowledge myself but I've encountered the following issues:
browserify
to see how everything can be bundled up together; however, it requires an entry point for the program, which our library does not really have as it is generally just a series of class declarations with functionality to interact with our organization's products.Am I missing some fundamental knowledge here? Is it feasible to use ES6 classes for what we're trying to accomplish, and if so, what would be a suggested workflow (in terms of tooling?) Or do we need to stay with namespaced classes for this kind of required output?
Upvotes: 0
Views: 200
Reputation: 275847
ES6 modules seem to be dependent on preserving a directory structure so this might mean we lose our namespaces
Not true in general, but this is how you would use them "within a project" when using typescript.
I'm not sure how we will later be able to access classes on an ES5 platform
Compile down to ES5 using a module pattern like --module commonjs
. Using commonjs
modules (aka NPM modules) is a well established pattern with major workflow tools out that that support it like webpack
, jspm
, browserify
.
which our library does not really have as it is generally just a series of class declarations with functionality to interact with our organization's products.
Create an index.ts
and export
the stuff that is your Libraries public api from it. This file is then your entry point.
Upvotes: 2