Subscribe on changes!

Use modules from `web_modules` if present

avatar
Apr 22nd 2020

Hey @yyx990803 thank you for putting this together, it will be super useful moving forward! I was inspired by the idea to integrate support for snowpack and gave an initial integration a try.

This assumes you have run npx snowpack in the directory you're working on, so I'm not calling it an integration quite yet.

However, this supports having modules present in web_modules and serving them as named packages directly from there. Quick example:

index.html:

<div id="app"></div>
<script type="module">
import { createApp } from 'vue'
import Comp from './Comp.vue'

createApp(Comp).mount('#app')
</script>

Comp.vue:

<template>
  <div>
    Today's date is: {{ dayjs().format('dddd MMMM D, YYYY') }}
  </div>
</template>

<script>
import dayjs from 'dayjs';
export default {
  methods: {
    dayjs
  }
}
</script>

Then run:

$ npm init -y
$ npm i --save dayjs
$ npx snowpack
$ npx vite

I'm curious to hear what you think about this.

avatar
Apr 22nd 2020

Oops, I clicked the Request re-review button a bit too early, I have another commit in the works :)

avatar
Apr 23rd 2020

Just wanted to say that this looks great! Happy to help answer any Snowpack questions that come up