Comments (3)
We also faced this issue in our project and implemented a transpileIsolated
function in our fork of deno_emit, which provides this exact functionality.
As an alternative, we also created a standalone TS transpiler based on deno_ast/deno_graph, that takes TS module code as an input and returns the transpiled JS code.
from deno_emit.
This is complicated and requires implementing something that could be built in, but it does prevent walking the entire import tree, so it's the most efficient.
This seems to cover your use case very well. Is there a compelling reason to make this behaviour built-in?
Can you explain your use-case a bit more? Maybe this is something that we can expect other people to need, but it is hard to tell until we know the why behind the use case.
from deno_emit.
There are two use cases here.
- Creating a JS library for browsers using Deno's tooling and ecosystem. While it may be standard to have one
mod.ts
file that re-exports everything, that isn't the only way to do things. In fact, I think that's bad practice for browser modules because it forces the browser to fetch all dependencies even if they're not needed for the current task. I'd rather just give deno_emit one directory and have it transpile all files inside it. - Creating a full-stack Deno web app. The browser scripts need to be transpiled from TS to JS, however I don't want to worry about which scripts are going to be entry points. Again, I just want to give deno_emit a directory and transpile all the files in it.
I suppose this could also apply to any project that has multiple entry points that rely on common code. For example, foo.ts
ultimately relies on common.ts
, and bar.ts
ultimately relies on common.ts
too. Both foo.ts
and bar.ts
are entry points, but since they both rely on common.ts
, common.ts
will get transpiled twice.
The behavior I'm proposing also mirrors tools like tsc
and babel
, which are transpilers, rather than webpack
and esbuild
, which are bundlers. In other words, it makes sense for deno_emit's bundle
to accept entry points and walk the tree, but it doesn't make sense to me to have transpile
walk the tree.
from deno_emit.
Related Issues (20)
- npm:specifier support HOT 1
- Inconsistent behavior regarding sourcemaps with tsc and deno bundle HOT 3
- Should `deno_emit` output ignore comments like `deno bundle`? HOT 1
- import not working offline, requires wasm HOT 2
- Please provide a way to generate .d.ts file
- Uncaught SyntaxError: Identifier 'mod' has already been declared
- error: Uncaught (in promise) Error: Unable to output during bundling. HOT 11
- Trailing slash added to base URL in transpile load function specifier HOT 4
- Uncaught ReferenceError: Deno is not defined HOT 1
- Better debugging output HOT 1
- Option to type check TypeScript? HOT 3
- Rust API?
- How to make bare import external? HOT 4
- Multiple `const mod =` definitions? HOT 3
- "Remote modules are not allowed to import local modules" HOT 3
- Cancellable API HOT 1
- feature request: output typescript
- Bundle fails when js deps include node modules
- `deno_emit::bundle_graph` only bundles the first root of `ModuleGraph`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno_emit.