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

Use Svelte v3 #5

Merged
merged 2 commits into from Jul 12, 2019
Merged

Use Svelte v3 #5

merged 2 commits into from Jul 12, 2019

Conversation

sisou
Copy link
Contributor

@sisou sisou commented Apr 1, 2019

I updated the packages and changed the file extension to .svelte.

I added the resolve() plugin so that the build includes the required svelte/internal helpers so the built component is able to run stand-alone. I think this is the expected behavior of this template?

@EmilTholin
Copy link
Member

I think you might want to use resolve just for the umd build, and set svelte/internal as an external dependency for the es build, but I'm not entirely sure.

E.g:

import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import pkg from './package.json';

const input = pkg.svelte;
const name = pkg.name
  .replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3')
  .replace(/^\w/, m => m.toUpperCase())
  .replace(/-\w/g, m => m[1].toUpperCase());

export default [
  {
    input,
    output: { file: pkg.main, format: 'umd', name },
    plugins: [
      svelte(),
      resolve()
    ]
  },
  {
    input,
    output: { file: pkg.module, format: 'es' },
    external: ['svelte/internal'],
    plugins: [svelte()]
  }
];

@wayne-o
Copy link

wayne-o commented Apr 30, 2019

This works for the most part but it seems to be ignoring content in <style> - has anyone else seen this?

@sisou
Copy link
Contributor Author

sisou commented May 6, 2019

I have tried it with

<script>
    export let name;
</script>

<h1>Hello {name}!</h1>

<style>
    h1 {
        color: rebeccapurple;
    }
</style>

and the CSS is included in the built files ( index.js and index.mjs).

@sisou sisou changed the title Use Svelte v3 (beta) Use Svelte v3 May 6, 2019
@YogliB
Copy link

YogliB commented May 31, 2019

Is this PR under review?

@sisou
Copy link
Contributor Author

sisou commented May 31, 2019

I think we have to ping @Rich-Harris, but I also remember him saying in Discord once that he has bigger plans for this repo than just a simple v3 update. He mentioned adding test infrastructure, IIRC.

But maybe this PR should still be merged until he finds time for that?

@YogliB
Copy link

YogliB commented Jun 1, 2019

@sisou

In the meantime, I've made a template based on the app and component templates.

It's Svelte 3 based, but other than that it works exactly the same and you can preview your component running npm run dev, just as you would do in a full-blown app.

@wayne-o
Copy link

wayne-o commented Jun 1, 2019 via email

@Conduitry Conduitry merged commit 2fa7518 into sveltejs:master Jul 12, 2019
@Conduitry
Copy link
Member

Sorry this sat for so long! I think there are still vague bigger plans for this repo, but this is definitely much better than the v2-only thing this template was before.

@antony
Copy link
Member

antony commented Jul 12, 2019

In case it's useful - I adapted the original repo to include livereload, making component development significantly easier.

https://github.com/antony/svelte-component-seed

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.

None yet

6 participants