DEV Community

Going Buildless

Pascal Schilp on July 30, 2019

Going Buildless Hi all ๐Ÿ‘‹ I'm in a long distance relationship, and this means that every few weeks I'm on a plane to England. Everytime ...
Collapse
 
westbrook profile image
Westbrook Johnson

This import maps things is pretty cool! When you used it to polyfill kv-storage you used /web_modules/kv-storage-polyfill.js as the initial call:

      โ€œ/web_modules/kv-storage-polyfill.js": [
        "std:kv-storage",
        "/web_modules/kv-storage-polyfill.js"
      ]
Enter fullscreen mode Exit fullscreen mode

Would it be possible to go the other way:

      โ€œstd:kv-storage": [
        "std:kv-storage",
        "/web_modules/kv-storage-polyfill.js"
      ]
Enter fullscreen mode Exit fullscreen mode

Which would allow the seemingly more โ€œcorrectโ€ import { StorageArea } from โ€˜std:kv-storageโ€™? Or maybe โ€œlong lastingโ€ is the better wordโ€ฆ

Collapse
 
thepassle profile image
Pascal Schilp

It seems that as of now, this is not possible, chrome will log the following in the dev tools:
Ignored an import map key "std:kv-storage": Invalid key (non-fetch scheme)

Even though, according to the spec that should be possible yeah: github.com/WICG/import-maps#for-bu...

Collapse
 
bennypowers profile image
Benny Powers ๐Ÿ‡ฎ๐Ÿ‡ฑ๐Ÿ‡จ๐Ÿ‡ฆ

What about importception

{
      "kv-storage": [
        "/web_modules/kv-storage-polyfill.js"
      ],
      "/web_modules/kv-storage-polyfill.js": [
        "std:kv-storage",
        "/web_modules/kv-storage-polyfill.js"
      ]
}

Then in use

import * as KvStorage from 'kv-storage';

Would that work?

Thread Thread
 
thepassle profile image
Pascal Schilp

Hehe, that'll still result in: Ignored an import map key "std:kv-storage": Invalid key (non-fetch scheme)

Thread Thread
 
westbrook profile image
Westbrook Johnson

What a shame...the future can't come fast enough!

Collapse
 
vedtam profile image
Edmond Varga • Edited

Thanks, that's really inspiring! I am often wondering how cool it would be to shake of rollup (and friends) as well, thanks to this post now I know the direction! :)

But regarding import-map, what about other browsers? Is there a polyfill maybe?

Collapse
 
thepassle profile image
Pascal Schilp

Yep, you can use es-module-shims for that

Collapse
 
vedtam profile image
Edmond Varga

Cool, thanks! :)

Collapse
 
seangwright profile image
Sean G. Wright

I love this exploration of the cutting edge of web development.

I used lit-html, dynamic imports, and Pika CDN recently on a little project and it was a wonderful experience.

I read up on import maps and the standard modules last year but didn't realize they had been deployed in Chrome (behind flags).

Thanks for coming up with this cool post to showcase the direction that JS browser tech is going!

Collapse
 
fredkschott profile image
Fred K. Schott

The latest version of @pika/web will even generate an import map for you automatically! You can check out the v0.5.0 release notes here for more info: github.com/pikapkg/web/releases/ta...

Loved this article, it does a great job of connecting a lot of really new and tricky stuff into one easy-to-follow story. Well done!

Collapse
 
thepassle profile image
Pascal Schilp

Woah, thats awesome! I'll play with that and update the blog when I tried it out ๐Ÿ˜Š

One thing to note is that I dont believe it's currently possible (in the Chrome implementation anyway) to load an import map as <script type="importmap" src="myImportMap.json"/>, though according to the spec something like this should be possible: github.com/WICG/import-maps#import...

Which may be a thing to document just in case.

Collapse
 
4nduril profile image
Tobias Barth

I made a thing for you:

npmjs.com/package/are-you-tired-yet

Collapse
 
thepassle profile image
Pascal Schilp

Hahaha dude thats awesome ๐Ÿ˜‚

Collapse
 
julien_chazal profile image
Julien Chazal

Thanks, going buildless is very interesting, but how do you uglify/minify your assets (JS, CSS, even images...) without a build step ?

Collapse
 
thepassle profile image
Pascal Schilp

For a long time, having a build step has been the de facto standard for frontend projects, and have added significant complexity and configuration to projects, and it's been hard to build anything without a build step.

As from this blog by Fred Schott A Future Without Webpack: "In 2019, you should use a bundler because you want to, not because you need to.", and today, we can.

This blogpost shows that we now have the standards (es modules, import maps) to do so; we can go buildless, and you can add a buildstep if you need to improve performance, but we dont require a buildstep. And many apps may not even need it, for example pika.dev, or this reddit app I showcase, or perflink by Luke Jackson.

There are also platforms that host your applications that can do minification for you, like Netlify. Netlify has options to minify your assets for you

Collapse
 
yurikaradzhov profile image
Yuri Karadzhov

Check out this project as well hqjs.org it might be the only tool you need. And it is as simple as one command to start development.

Collapse
 
atla5 profile image
Aidan Sawyer

I got tripped up briefly by import-maps not already being enabled by default (yet!). Here's the link to enable this functionality in chrome.