Comments (8)
I am not sure exactly what you mean. Do you suggest the Bundler API to take a string as input for transpilation?
from bundler.
So, since there is no script file as entry points in my case, the idea would be to provide the raw source as a strings for all script contents inside the template language.
To pain the picture.
The template language can take components. Each component can implement script blocks as they see fit for client side code. The template language is only run in deno with the goal of shipping html.
So if I passed all strings as possible entry points, the idea would be to concat those together and also bundle any dependencies. Dependencies could be external from the Templar language and done in plain JS/TS.
Does that make sense?
from bundler.
So you mean to bundle together multiple entry points?
This is not possible because files might have same named exports.
What you can do however is make a bundle like this
import "./entry1.ts"
import "./entry2.ts"
and set that as the entry. But this should also possible with Deno.bundle.
from bundler.
We are not referring to the same thing.
What I am saying is you do not have files to bundle in my scenario.
Or atleast not a good set of them. Any imports they refer to can be. But I am saying I need to provide a set of raw source strings. I can't give a file name because you have nothing to parse as the entry point.
But if I give a raw source string, can you start bundling from there?
As far as multiple entry points, it's more like a concatenation. None of those raw source strings can import each other, since they are in the template language.
from bundler.
Sorry, my last response was from my mobile phone. Let me try to build a better example.
src/components/file-a
<script>
import y from 'something.ts';
let x = "foo";
y(x)
</script>
src/components/file-b
<script>
import y from 'something.ts';
let x = "bar";
y(x)
</script>
The basic idea is that I want to pass the contents of the file-a, and file-b if they are used on the same page.
Since these are template files, they are not something parsable I would assume without a lot of effort. So the idea would be to pass the raw strings of the script blocks insides. The bundler would concat, and prevent name collisions and deal with resolving imports. Basically everything that bundlers already do.
I know if this was rollup or webpack, this is the basic concept of how they work today when working with React, Svelte, or Vue.
Does that help clarify the issue?
from bundler.
Ok, I think it is a good idea to have Bundler API provide a way to transpile/bundle strings instead of files.
Until then: It seems to me what you want is doable with Deno.bundle
:
const [diagnostics, emit] = await Deno.bundle("/index.ts", {
"/index.ts": `import "./entry1.ts"; import "./entry2.ts";`,
"/entry1.ts": `import y from "./something.ts"; let x = "foo"; y(x);`,
"/entry2.ts": `import y from "./something.ts"; let x = "bar"; y(x);`,
"/something.ts": `export default function (x: string) { console.log(x); }`,
})
from bundler.
Correct. Yeah and I was thinking of maybe a similar interface.
The issue with Deno.bundle is that it will only do ES modules and I don't think there is a path for older browsers.
It's why I raised this.
I was also looking at ESBUILD which has a WASM browser api, that is way faster than rollup, (100x) but it does not bundle with WASM you would need the go executable.
from bundler.
0.2.0 is out. It now takes an InputMap and an OutputMap for bundling.
from bundler.
Related Issues (20)
- how to disable export default in final js bundle file? HOT 2
- Use as a api HOT 2
- API: bundle function don't write output assets HOT 2
- API doc
- hello_world examples not working HOT 1
- Generic lambda compiled as React components HOT 1
- export default is working only with function HOT 1
- bundler and bundler api are not emiting javascript output HOT 3
- examples/server don't work HOT 2
- spa dev server example HOT 1
- project struture in read me HOT 1
- API Examples failing
- Feature Request: Support circular dependencies HOT 3
- Bundler fails to run when trying to import `acorn` via `terser` HOT 5
- Crash with CSS Gradients: `TypeError: i.walkFunctionNodes is not a function` HOT 3
- Does not understand .mjs extension / script type HOT 1
- Fails to download one of the dependency files HOT 3
- Bundler misinterprets Windows path as a url HOT 4
- Newline behavior HOT 4
- Guide for create pluging HOT 2
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 bundler.