Git Product home page Git Product logo

template's Introduction

This repo is no longer maintained. Consider using npm init vite and selecting the svelte option or — if you want a full-fledged app framework — use SvelteKit, the official application framework for Svelte.


svelte app

This is a project template for Svelte apps. It lives at https://github.com/sveltejs/template.

To create a new project based on this template using degit:

npx degit sveltejs/template svelte-app
cd svelte-app

Note that you will need to have Node.js installed.

Get started

Install the dependencies...

cd svelte-app
npm install

...then start Rollup:

npm run dev

Navigate to localhost:8080. You should see your app running. Edit a component file in src, save it, and reload the page to see your changes.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the sirv commands in package.json to include the option --host 0.0.0.0.

If you're using Visual Studio Code we recommend installing the official extension Svelte for VS Code. If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.

Building and running in production mode

To create an optimised version of the app:

npm run build

You can run the newly built app with npm run start. This uses sirv, which is included in your package.json's dependencies so that the app will work when you deploy to platforms like Heroku.

Single-page app mode

By default, sirv will only respond to requests that match files in public. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.

If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for any path. You can make it so by editing the "start" command in package.json:

"start": "sirv public --single"

Using TypeScript

This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:

node scripts/setupTypeScript.js

Or remove the script via:

rm scripts/setupTypeScript.js

If you want to use baseUrl or path aliases within your tsconfig, you need to set up @rollup/plugin-alias to tell Rollup to resolve the aliases. For more info, see this StackOverflow question.

Deploying to the web

With Vercel

Install vercel if you haven't already:

npm install -g vercel

Then, from within your project folder:

cd public
vercel deploy --name my-project

With surge

Install surge if you haven't already:

npm install -g surge

Then, from within your project folder:

npm run build
surge public my-project.surge.sh

template's People

Contributors

akauppi avatar antonwiklund99 avatar antony avatar benmccann avatar benschac avatar bevand10 avatar cainux avatar conduitry avatar crisfole avatar dummdidumm avatar emiltholin avatar frederikhors avatar ivansanchez avatar jacoblukewood avatar jul-sh avatar kandersonko avatar lukeed avatar matyifkbt avatar mehedi61 avatar milahu avatar nesro avatar nymous avatar orta avatar pascalhonegger avatar paulbgd avatar peopledrivemecrazy avatar rich-harris avatar romankaravia avatar theo-steiner avatar therealparmesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

template's Issues

Proposal: Don't start serving until the bundle has been written

I'm hoping this will help with people requesting http://localhost:5000/bundle.js before the file's ready, which hopefully will get rid of the epidemic of the "unexpected token <" errors.

What if we didn't start npm run start:dev until the writeBundle hook in Rollup has been called? This could be called with child_process.exec or something in a one-off plugin that's only used when we're not in production mode. If the server's not even running yet, hopefully the browser won't try to cache anything.

As an added bonus (and this one would be worth it by itself imo) we would be able to drop npm-run-all which has twelve trillion dependencies.

Add rollup plugins with Livereload and serve 🤫

1. package.json Add plugins and Clean scripts

"rollup-plugin-livereload": "^0.6.0"
"rollup-plugin-serve": "^0.4.2",

clean serve , or even npm-run-all if you want

{
  "name": "svelte-app",
  "version": "1.0.0",
  "devDependencies": {
    "npm-run-all": "^4.1.3",
    "rollup": "^0.58.2",
    "rollup-plugin-buble": "^0.19.2",
    "rollup-plugin-commonjs": "^9.1.3",
    "rollup-plugin-livereload": "^0.6.0",
    "rollup-plugin-node-resolve": "^3.0.3",
    "rollup-plugin-serve": "^0.4.2",
    "rollup-plugin-svelte": "^4.0.0",
    "rollup-plugin-uglify": "^3.0.0",
    "svelte": "^2.6.0"
  },
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w"
  }
}

2. Add plugins to rollup.config.js

import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
// ...

		production && uglify(),
		serve("public"),      // index.html should be in root of project
    	livereload("public")

Already Done Demo❤️

https://github.com/chinanf-boy/try-svelte-my-new-project-templete

you Edit the repo after you try or maybe I pull

Using scss files

How to add .scss files?

Maybe need an integration with rollup-plugin-svelte.

A question about "sirv".

I know I'm not following the rules of common sense by opening an issue that I might not open.

But I believe that a wonderful project like svelte requires good tools.

sirv is at a very early stage and cannot compete with tools like browsersync or others already mentioned here (#8) and here (#17).

Please understand our complaints as daily developers.

Thank you.

Unexpected token < with default template

I haven't added any logic to the app, it's just this template. I tried to run it with yarn start:dev, which is sirv public --single --dev.

This is the project that I'm trying to implement. I don't know if is my Operative System or Node version, which are:

  • Node: v10.16.3
  • Npm: 6.9.0
  • Linux: Linux Mint 19.1 Tessa

Error:

Screenshot_2019-08-18_21-41-52

Output from the console when loads the page:

Screenshot_2019-08-18_21-42-42

Also, I tried running the build command and then the start:dev and it did not work

Consider disabling terser plugin (temporarily)

terser/terser#443 is a bug in terser which is triggered any time it's run over compiled Svelte code that uses {#await}. The code it produces throws an exception at runtime.

As someone who lost an hour or two trying to figure out why my production build, based on this starter template, was failing, I wonder if it's worth disabling the terser plugin by default, with a comment pointing back to that issue and instructions that it's safe to enable if you're not using {#await}, until terser is able to release a fix?

Unexpected token function

Steps I have taken

  1. Unzipped the REPL package from https://svelte.dev into project folder
  2. Ran 'npm install'
  3. Ran 'npm run build'

Get the following error:
`PS D:\Projects\GitHub\MediaSwitcher> npm run build

[email protected] build D:\Projects\GitHub\MediaSwitcher
rollup -c

[!] SyntaxError: Unexpected token function
D:\Projects\GitHub\MediaSwitcher\node_modules\svelte\compiler.js:23956
async function replace_async(str, re, func) {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions..js (D:\Projects\GitHub\MediaSwitcher\node_modules\rollup\dist\bin\rollup:841:17)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: rollup -c
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nev\AppData\Roaming\npm-cache_logs\2019-09-09T23_01_30_133Z-debug.log
PS D:\Projects\GitHub\MediaSwitcher>`

When i want use socket.io-client , But it's look like packaged some node.js modules.

import io from "socket.io-client";    
main.js:8 Uncaught ReferenceError: os is not defined  at main.js:8

If i use dist/socket.io

import io from "socket.io-client/dist/socket.io";
Uncaught TypeError: Cannot read property 'Buffer' of undefined
    at Object.<anonymous> (socket.io.js:6)

If i want parcel the lib run in browser 。 how to ? thanks.

FYI: fix for failing auto rebuild on Windows

Hi,

I followed the instructions from the guide to install the template.
Installation went smooth and after npm run dev I got the "serving" message. However going to localhost:5000 got me a blank screen.

Looking at package.json in the template npm run dev does:
"dev": "serve public & rollup -c -w"
which works great on Linux and Mac , but not on Windows.

The solution is quite simple:

  • add "npm-run-all to the devDependencies
  • change the scripts section into:
"scripts": {
    "build": "rollup -c",
    "autobuild": "rollup -c -w",
    "dev": "run-p start autobuild",
    "start": "serve public"
  }

This way the scripts are not depending on OS-specific features.

Cheers,
Hans

SPA mode

I think we should change this:

"start:dev": "sirv public --dev"

to this:

"start:dev": "sirv public --dev -s"

because of this: kazzkiq/svero#16.

Rollup doesn't know changes of any *.svelte in child directory in src

Issue (MacOS 10.14.5):
If you have App.svelte in /src/ and Tab.svelte, TabItem.svelte in /src/components/,
App import Tab, Tab import TabItem,
Rollup doesn't know changes in TabItem, but it knows changes in Tab.

Solution:

		svelte({
			// enable run-time checks when not in production
			dev: !production,
			include: 'src/**/*.svelte', // add this
			// we'll extract any component CSS out into
			// a separate file — better for performance
			css: css => {
				css.write('public/bundle.css');
			}
		}),

Please help! error ! could not find commit hash for master

I have already checked other threads but I am not sure how to fix this, I tried out a few things, but it did not work please help

C:\Users\Admin\Desktop>npx degit sveltejs/template svelte-app ! could not find commit hash for master

this library seems amazing please help so I can use it. I am a noob when it comes to nodejs. Have been web developing in html+css+js up till now.

changes to global.css do not trigger live reload

Changing styles in global.css does not trigger a live reload.
Manually refreshing the browser does apply the changes.

Information about your Svelte project:

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)
    Chrome Version 77.0.3865.90

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)
    macOS 10.14.6

  • Svelte version (Please check you can reproduce the issue with the latest release!)
    3.12.1

  • Whether your project uses Webpack or Rollup
    Rollup

Sirv didn't hot-reload

After running npm run dev, changing to Helllooo {name}!! in App.svelte didn't trigger hot reload, I had to manually refresh browser.

Tried similar http server: npm install live-server --save-dev, and edit package.json scripts, it works

build error

just tried to svelte, downladed this template and get error ->

Capture

and package json have old versions why no one update this?

Buble and Uglify interplay

Hi!

I've long used this template without issue, but I recently updated rollup-plugin-uglify to version 4 (which removed support for anything beyond ES5) in a project, and I found that it couldn't actually process the output of buble, which emits this object shorthand:

var proto = {
	destroy,
	get,
	fire,
	on,
	set,
	_recompute: noop,
	_set,
	_mount,
	_differs
};

Removing the exclude: 'node_modules/**' from the rollup-plugin-buble config fixed this for me. (I'm guessing this exclusion was more appropriate before Svelte 2 stopped emitting ES5 code.)

The current configuration of this template actually does seem to produce working ES5 code (haven't actually tested on IE or anything...), because when you use the Uglify that works with post ES5 code, it actually happens to remove the object shorthand. 🤷🏻‍♂️

Which is all to say, everything in the template is fine at the moment as far as ES5 support goes, but this might be something to look out for if you update dependencies. And there's probably a bunch of people using this template currently who then try to update dependencies on their own and run into something along these lines. Dunno if removing the exclude node-modules config and/or switching to rollup-plugin-terser, or just dropping legacy browser support for the template is the most appropriate move, but I hope this is a helpful note for someone! 😊

Edge can't handle global.css input[type="range"] styling

This is most likely an Edge issue but I'll report this anyway.

global.css has following definition:

input[type="range"] {
	height: 0;
}

Setting the height to 0 makes range slider thumb completely invisible on Edge.
In general, why is that style definition in global.css at all?

Example of babel integration

Can we get an example of how to use babel with the svelte template?

Try as I may, I can't get transforms to work correctly on all the bundle code and polyfills are none existent as well. I'm sure it's some configuration issue, but having an example to work from would be great for the community.

Default clearScreen to false

Expected Behavior:

Running npm run dev should make both Sirv and Rollup output some infos to screen.

Actual Behavior:

As soon as Sirv output infos, Rollup's infos covering it.

Proposal:

Please add watch: { clearScreen: false } as default in rollup.config.js, so new user can see what port Svelte's running.

I also have submitted this issue in Rollup repo.

Svelte await blocks cause breaking errors in Terser's compression step

Problem?

Terser is doing its thing for production builds. It carries out a second compression on bundle.js that results in a breaking JS error if any Svelte files contain {#await ...} blocks.

Recreate the bug

  1. Add a Svelte file with an await block into your application
  2. Run a production build npm run build
  3. Serve up the public directory
  4. Observe dead site

Screenshot 2019-08-30 at 17 18 17

Fix

Since the second pass of compression on bundle.js is superfluous and causes a bug, it should be removed from the Terser plugin's build step. #58

Move index.html and global.css to /src

Just a suggestion; but it would be more helpful to have index.html and global.css in the /src folder and copied to /public on build.
I made the mistake of copying everything in a test project except /node_modules and /public expecting to be able to rebuild from there; and then realised that I had no index.html. Others might add a clean process to their build pipeline and wipe those files out that way...

eslint default rc file

Can we add an .eslintrc.js (or other names) for eslinting?

Using eslint-plugin-svelte3.

Degit execution does not work

Doc says to just run degit sveltejs/template svelte-app

Results:

$ degit sveltejs/template svelte-app
! could not find commit hash for master

EDIT:
OS: Linux Manjaro 18.1.0 Juhraya
Git is installed and I use it everyday without any problems.
git version 2.23.0
Node: v12.9.1
NPM: 6.11.2
Degit: 2.1.4

Template is unlicensed

I know this code is pretty trivial, but it might it might still help to have a license.

From the GitHub guidance on licensing:

You're under no obligation to choose a license. However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work. If you're creating an open source project, we strongly encourage you to include an open source license. The Open Source Guide provides additional guidance on choosing the correct license for your project.

Vulnerability found in ws dependency

Just bootstrapped a new svelte project using this template and pushed it to Github. Github now notifies me with a vulnerability warning for the dependency ws. The dependency belongs to rollup-plugin-livereload#livereload, as shown with yarn why ws.

There's an open ticket in livereload to address this vulnerability: napcs/node-livereload#130. Yet I still opened this ticket to bring visibility.

image

yarn why ws
=> Found "[email protected]"
info Reasons this module exists
   - "rollup-plugin-livereload#livereload" depends on it
   - Hoisted from "rollup-plugin-livereload#livereload#ws"

Linters for template

What do you think about the linter configuration in the template?
For example for eslint and prettier.
Using a template, I would not want to have a cognitive load when installing plugins for linter etc

sirv-cli in dependencies

I recently had trouble deploying a svelte app to heroku. Sirv wouldn't run. Got me some time until the solution came: the dependency is under "devDependencies" and not "dependencies" in package.json. Heroku strip out those packages after build and server will crash.

Of course sirv is great for development scenarios where things are simple and straightforward, but nonetheless I feel like the template could just be production-ready. As the app scales packages will be added/changed anyway.

Doesn't work on Safari

Hey,

I was checking out the project, and, while testing the app (after only installing dependencies and running yarn dev), I noticed it's not working on safari at all.

I didn't have a lot of time to dig in this, but, for some reason, the bundle.js file is imported with the content of the index.html, which causes a parsing error. It's only happening on Safari, though.

I thought I'd report it. If I get the chance, I'll check the code and try to open some PR.

Thanks

ValidationError: Home component is not defined

Error: [!] (svelte plugin) ValidationError: Home component is not defined

Project structure:

src
 - App.html
 - Home.html
 - main.js
App.html

<h1>Hello {name}!</h1>
<Home></Home>
Home.html
<h2>Home</h2>
main.js

import App from './App.html';
import Home from './Home.html';

const app = new App({
  target: document.body,
  data: {
    name: 'world'
  },
  components: {Home}
});
export default app;

I'm still trying to read the generated js files to see what I'm doing wrong. Will update soon as I made any progress.

Development builds should warn developer of compile errors in the browser

A common problem during Svelte development is when you reload your app in the browser and don't see your changes. After a few minutes, you realize that it's because your code failed to compile.

For dev builds only, Svelte bundle.js should include another Javascript file. e.g. error.js When you compile your app, the compiler will write a function to that file:

// SUCCESSFUL COMPILE
function compileErrors() {
   return "";
}

or

// FAILED TO COMPILE
function compileErrors() {
   return "(!) Plugin svelte: A11y: <img> element should have an alt attribute
src/HUD.svelte
67:   <div id="hud-overlay">
68:     <div class="hud">
69:       <img src="/image.png" />
          ^
70:       <p>Added</p>
71:     </div>
";
}

When your Svelte bundle.js is loaded, it loads error.js (only during development) and calls compileErrors(). If it returns "", the app runs normally. Otherwise, it displays the compile errors in the browser:

image

It's a small change that will boost our productivity. Please consider it.

Livereload broken

Livereload does not work with this template as of the lastest livereload version 0.8.1.

To replicate, run

npx degit sveltejs/template bugtest
cd bugtest
npm install
npm run dev

Then open your browser at localhost:5000 and edit the svelte project in your editor. Changes does not automatically reload the page.

Editing the package-lock.json by replacing the livereload entry with "livereload": { "version": "0.8.0" } worked for me.

Comparing final bundle size with svelte/template (rollup) and svelte/template-webpack

I'm comparing github.com/sveltejs/template and github.com/sveltejs/template-webpack.

I expected the final bundle to be the same with the same codebase.

What I did:

  • Cloned both template using degit

  • Removed sourcemap for js files in rollup.config.js, line 12: sourcemap: false

  • Removed line 10 (window.app = app;) in main.js for webpack template (now the two main.js are equal in content)

  • Updated all dependencies to:

    • sveltejs/template (Rollup), package.json:
{
  "name": "svelte-app",
  "version": "1.0.0",
  "devDependencies": {
    "npm-run-all": "4.1.5",
    "rollup": "1.12.2",
    "rollup-plugin-commonjs": "10.0.0",
    "rollup-plugin-livereload": "1.0.0",
    "rollup-plugin-node-resolve": "5.0.0",
    "rollup-plugin-svelte": "5.0.3",
    "rollup-plugin-terser": "4.0.4",
    "sirv-cli": "0.4.2",
    "svelte": "3.4.1"
  },
  "scripts": {
    "build": "rollup -c",
    "autobuild": "rollup -c -w",
    "dev": "run-p start:dev autobuild",
    "start": "sirv public",
    "start:dev": "sirv public --dev"
  }
}
  • sveltejs/template-webpack (Webpack), package.json:
{
  "name": "svelte-app",
  "version": "1.0.0",
  "devDependencies": {
    "cross-env": "5.2.0",
    "css-loader": "2.1.1",
    "mini-css-extract-plugin": "0.6.0",
    "serve": "11.0.0",
    "style-loader": "0.23.1",
    "svelte": "3.4.1",
    "svelte-loader": "2.13.4",
    "webpack": "4.31.0",
    "webpack-cli": "3.3.2",
    "webpack-dev-server": "3.4.1"
  },
  "scripts": {
    "build": "cross-env NODE_ENV=production webpack",
    "dev": "webpack-dev-server --content-base public"
  }
}

Results:

  • For Rollup one:
var app=function(){"use strict";function t(){}function n(t){return t()}function e(){return Object.create(null)}function r(t){t.forEach(n)}function o(t){return"function"==typeof t}function c(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function a(t,n){t.appendChild(n)}function u(t){return document.createTextNode(t)}let f;function s(t){f=t}const i=[],d=Promise.resolve();let l=!1;const $=[],m=[],p=[];function h(t){m.push(t)}function g(){const t=new Set;do{for(;i.length;){const t=i.shift();s(t),y(t.$$)}for(;$.length;)$.shift()();for(;m.length;){const n=m.pop();t.has(n)||(n(),t.add(n))}}while(i.length);for(;p.length;)p.pop()();l=!1}function y(t){t.fragment&&(t.update(t.dirty),r(t.before_render),t.fragment.p(t.dirty,t.ctx),t.dirty=null,t.after_render.forEach(h))}function _(t,n){t.$$.dirty||(i.push(t),l||(l=!0,d.then(g)),t.$$.dirty=e()),t.$$.dirty[n]=!0}function x(c,a,u,i,d,l){const $=f;s(c);const m=a.props||{},p=c.$$={fragment:null,ctx:null,props:l,update:t,not_equal:d,bound:e(),on_mount:[],on_destroy:[],before_render:[],after_render:[],context:new Map($?$.$$.context:[]),callbacks:e(),dirty:null};let y=!1;var x;p.ctx=u?u(c,m,(t,n)=>{p.ctx&&d(p.ctx[t],p.ctx[t]=n)&&(p.bound[t]&&p.bound[t](n),y&&_(c,t))}):m,p.update(),y=!0,r(p.before_render),p.fragment=i(p.ctx),a.target&&(a.hydrate?p.fragment.l((x=a.target,Array.from(x.childNodes))):p.fragment.c(),a.intro&&c.$$.fragment.i&&c.$$.fragment.i(),function(t,e,c){const{fragment:a,on_mount:u,on_destroy:f,after_render:s}=t.$$;a.m(e,c),h(()=>{const e=u.map(n).filter(o);f?f.push(...e):r(e),t.$$.on_mount=[]}),s.forEach(h)}(c,a.target,a.anchor),g()),s($)}class b{$destroy(){var n,e;e=!0,(n=this).$$&&(r(n.$$.on_destroy),n.$$.fragment.d(e),n.$$.on_destroy=n.$$.fragment=null,n.$$.ctx={}),this.$destroy=t}$on(t,n){const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(n),()=>{const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}$set(){}}function v(n){var e,r,o,c;return{c(){var t;t="h1",e=document.createElement(t),r=u("Hello "),o=u(n.name),c=u("!"),e.className="svelte-i7qo5m"},m(t,n){!function(t,n,e){t.insertBefore(n,e||null)}(t,e,n),a(e,r),a(e,o),a(e,c)},p(t,n){var e,r;t.name&&(e=o,r=""+(r=n.name),e.data!==r&&(e.data=r))},i:t,o:t,d(t){var n;t&&(n=e).parentNode.removeChild(n)}}}function w(t,n,e){let{name:r}=n;return t.$set=(t=>{"name"in t&&e("name",r=t.name)}),{name:r}}return new class extends b{constructor(t){super(),x(this,t,w,v,c,["name"])}}({target:document.body,props:{name:"world"}})}();
  • For Webpack one:
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(2)},function(t,e,n){},function(t,e,n){"use strict";function r(){}n.r(e);function o(t){return t()}function c(){return Object.create(null)}function u(t){t.forEach(o)}function a(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}new Set;function s(t,e){t.appendChild(e)}function f(t){return document.createElement(t)}function l(t){return document.createTextNode(t)}let d;function p(t){d=t}const $=[],m=Promise.resolve();let h=!1;const y=[],b=[],g=[];function x(){h||(h=!0,m.then(v))}function _(t){b.push(t)}function v(){const t=new Set;do{for(;$.length;){const t=$.shift();p(t),O(t.$$)}for(;y.length;)y.shift()();for(;b.length;){const e=b.pop();t.has(e)||(e(),t.add(e))}}while($.length);for(;g.length;)g.pop()();h=!1}function O(t){t.fragment&&(t.update(t.dirty),u(t.before_render),t.fragment.p(t.dirty,t.ctx),t.dirty=null,t.after_render.forEach(_))}let j;function w(t,e){t.$$&&(u(t.$$.on_destroy),t.$$.fragment.d(e),t.$$.on_destroy=t.$$.fragment=null,t.$$.ctx={})}function S(t,e,n,i,s,f){const l=d;p(t);const m=e.props||{},h=t.$$={fragment:null,ctx:null,props:f,update:r,not_equal:s,bound:c(),on_mount:[],on_destroy:[],before_render:[],after_render:[],context:new Map(l?l.$$.context:[]),callbacks:c(),dirty:null};let y=!1;var b;h.ctx=n?n(t,m,(e,n)=>{h.ctx&&s(h.ctx[e],h.ctx[e]=n)&&(h.bound[e]&&h.bound[e](n),y&&function(t,e){t.$$.dirty||($.push(t),x(),t.$$.dirty=c()),t.$$.dirty[e]=!0}(t,e))}):m,h.update(),y=!0,u(h.before_render),h.fragment=i(h.ctx),e.target&&(e.hydrate?h.fragment.l((b=e.target,Array.from(b.childNodes))):h.fragment.c(),e.intro&&t.$$.fragment.i&&t.$$.fragment.i(),function(t,e,n){const{fragment:r,on_mount:c,on_destroy:i,after_render:s}=t.$$;r.m(e,n),_(()=>{const e=c.map(o).filter(a);i?i.push(...e):u(e),t.$$.on_mount=[]}),s.forEach(_)}(t,e.target,e.anchor),v()),p(l)}"undefined"!=typeof HTMLElement&&(j=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}$destroy(){w(this,!0),this.$destroy=r}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}});class k{$destroy(){w(this,!0),this.$destroy=r}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}}n(1);function M(t){var e,n,o,c;return{c(){e=f("h1"),n=l("Hello "),o=l(t.name),c=l("!"),e.className="svelte-i7qo5m"},m(t,r){!function(t,e,n){t.insertBefore(e,n||null)}(t,e,r),s(e,n),s(e,o),s(e,c)},p(t,e){var n,r;t.name&&(n=o,r=""+(r=e.name),n.data!==r&&(n.data=r))},i:r,o:r,d(t){var n;t&&(n=e).parentNode.removeChild(n)}}}function C(t,e,n){let{name:r}=e;return t.$set=(t=>{"name"in t&&n("name",r=t.name)}),{name:r}}const E=new class extends k{constructor(t){super(),S(this,t,C,M,i,["name"])}}({target:document.body,props:{name:"world"}});e.default=E}]);

What I'm scared:

With more packages and components the difference for final bundle in size is about >15KB (rollup is smaller).

Why does webpack's weigh more?

This scares me.

Browser doesn't pick up code changes

Description:

Browser is somehow caching the bundle.js. In Chrome dev tools, when I click on a .svelte class in an error message, it shows me an older version of the class.

Environment:

Browser: Chrome 77.0.3865.120 (Official Build) (64-bit)
OS: macOS Mojave 10.14.6 (18G103)

I am using the "dev" target for yarn/npm:

"dev": "run-p start:dev autobuild",

Severity:

This is blocking my development w/Svelte.

Rollup console log covering Sirv's

When I run
npm run dev

As soon as appeared Sirv's:
Your application is ready~! 🚀
- Local: http://localhost:5000
- Network: http://192.168.0.200:5000

then appeared Rollup's:
rollup v1.4.1
bundles src/main.js → public/bundle.js...
created public/bundle.js in 240ms
[2019-03-06 17:19:39] waiting for changes...

Please let Sirv's console log appear so we know what port Svelte's running.

What does "window.app = app;" mean?

The content of main.js in github.com/sveltejs/template-webpack:

import App from './App.svelte';

const app = new App({
	target: document.body,
	props: {
		name: 'world'
	}
});

window.app = app;

export default app;

The same file in github.com/sveltejs/template:

import App from './App.svelte';

const app = new App({
	target: document.body,
	props: {
		name: 'world'
	}
});

export default app;

I'm wondering what difference window.app = app; means.

Can you answer please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.