Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support remapping imports at link time #47

Merged
merged 4 commits into from
Jan 30, 2024
Merged

Conversation

Quafadas
Copy link

This adds the ability to remap imports at link time.

The extra test checks validation of the new flag.

The final output in the new test is the happy path. Hosting the "index.html" file it puts out it in a browser automatically resolves the import and successufully prints to the console (we don't test this, only that the import is correctly remapped int he JS file).

The motivation for the PR is that it would appear to have the potential to sweep away parts of the existing (complicated) toolchain for certain scala-js use cases.

Copy link

@Gedochao Gedochao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, commented on nitpicks

@Gedochao Gedochao changed the title Import map fro scala-js Support remapping imports at link time Jan 29, 2024
@Gedochao Gedochao requested a review from armanbilge January 29, 2024 11:16
@Gedochao Gedochao merged commit ade123e into VirtusLab:main Jan 30, 2024
7 checks passed
lefou added a commit to com-lihaoyi/mill that referenced this pull request May 16, 2024
# Motivation

I'm really enjoying frontend scala, without needing to configure an
entire node / npm environment. The capability to use the JS ecosystem
without a bundler, is the "build primitive", that enables this. Here's a
longer discussion of the motivation

VirtusLab/scala-cli#1968 (comment)

# Implementation
arman added this to SBT here and published a library that does the heavy
lifting.
https://github.com/armanbilge/scalajs-importmap

I followed this up in scala-cli ... 
VirtusLab/scala-js-cli#47

... and am really enjoying this in the small. My larger projects are in
mill though (thanks :-)!). Hence... this PR... which seeks to integrate
the capability into mill. I wanted to do it in a plugin - but I couldn't
see how as the call to the linker is in a private scope - so I've put it
up for mill itself.

I would expect this as is to pass CI with the new test. Very open to
feedback. If accepted, it would be my first contribution to mill ... I'd
be a little surprised if I got everything right straight out the gate -
a plugin may indeed be preferable if I have not correctly understood the
constraints.

Pull request: #3109

---------

Co-authored-by: Tobias Roeser <le.petit.fou@web.de>
Co-authored-by: Lorenzo Gabriele <lorenzolespaul@gmail.com>
Co-authored-by: Romain Gilles <58700468+romain-gilles-ultra@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants