Giter Site home page Giter Site logo

Provide Source about bundler HOT 8 CLOSED

timreichen avatar timreichen commented on May 28, 2024
Provide Source

from bundler.

Comments (8)

timreichen avatar timreichen commented on May 28, 2024

I am not sure exactly what you mean. Do you suggest the Bundler API to take a string as input for transpilation?

from bundler.

khrome83 avatar khrome83 commented on May 28, 2024

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.

timreichen avatar timreichen commented on May 28, 2024

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.

khrome83 avatar khrome83 commented on May 28, 2024

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.

khrome83 avatar khrome83 commented on May 28, 2024

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.

timreichen avatar timreichen commented on May 28, 2024

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.

khrome83 avatar khrome83 commented on May 28, 2024

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.

timreichen avatar timreichen commented on May 28, 2024

0.2.0 is out. It now takes an InputMap and an OutputMap for bundling.

from bundler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.