troll icon indicating copy to clipboard operation
troll copied to clipboard

Does gjspack plan on supporting custom file handlers?

Open ranfdev opened this issue 3 years ago • 3 comments

From the gjspack readme:

Support other programming languages? Ping me if there is any interest.

I'd like being able to import .cljs (ClojureScript) files and have them executed as javascript. This can be done by pre-processing the .cljs with a ClojureScript compiler or even just https://github.com/squint-cljs/squint.

I was thinking about having a config file similar to

export default {
  importHandlers: {
    "/.*\.blp/": {
      command: "blueprint compile $match",
      generates: "$match.ui",
      importType: "builder",
    }
    "/.*\.cljs/": {
      command: "squint compile $match",
      generates: "$match.js",
      importType: "js",
    },
  }
}

Edit: Probably having a custom config file is not the best idea and we should follow the conventions set by webpack, or rollup...

ranfdev avatar Sep 12 '22 06:09 ranfdev

The only reason I made gjspack instead of extending rollup is because I want to maintain clean stack traces by not altering sources. (By bundling in a .gresource instead of in a single .js entry file).

If you're gonna compile your source anyway and loose clean stack traces – I think using rollup directly makes more sense. gjs might support source maps at some point too https://gitlab.gnome.org/GNOME/gjs/-/issues/474

One could make a rollup plugin to support gjspack features such as importing assets and generating a .resource

Such a simple interface also doesn't work well for Blueprint because the CLI compiler is too slow for the DX I'm aiming for. I'm currently experimenting with using compile-batch or LSP.

On the other hand, I might extend gjspack to be more than just a bundler. Long story short, I'm not totally against it and I'd accept a PR if someone really wants to use gjspack and is willing to implement and help maintain this.

sonnyp avatar Sep 12 '22 18:09 sonnyp

So I'd like to experiment more with JSX in GJS. I still want to keep stack traces. The only transformer I know of which can do this is babel with the retainLines option.

Having custom file handlers would help with that.

Such a simple interface also doesn't work well for Blueprint because the CLI compiler is too slow for the DX I'm aiming for. I'm currently experimenting with using compile-batch or LSP.

This is not true anymore since https://gitlab.gnome.org/jwestman/blueprint-compiler/-/commit/06f54c8ff8d5f7c78c1d21bcbc59fdd87ce14910

So Blueprint could become a generic file handler as well.

sonnyp avatar Oct 21 '22 15:10 sonnyp

I added support for custom transforms https://github.com/sonnyp/troll/commit/f831dcd68cbcb587469414c8f091c40cf9e1e7b0

It only supports “assets” for now. The plan next is to support source files.

sonnyp avatar Jan 14 '23 00:01 sonnyp