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

(!) Plugin svelte: 'Event' is not defined #73

Closed
Joxtacy opened this issue Oct 27, 2019 · 4 comments
Closed

(!) Plugin svelte: 'Event' is not defined #73

Joxtacy opened this issue Oct 27, 2019 · 4 comments

Comments

@Joxtacy
Copy link

Joxtacy commented Oct 27, 2019

I just set up a small svelte app and in that app I am creating a new Event('submit') to be able to trigger my form's on:submit handler. It all works fine and dandy but when I build it I get this message:

rollup v1.25.2
bundles src/index.js → dist/bundle.js...
LiveReload enabled
http://localhost:5000 -> /Users/joxtacy/PrivateProjects/try-out-svelte/dist
(!) Plugin svelte: 'Event' is not defined
src/Todos.svelte
46:     </label>
47:     <div class="add-button"
48:          on:click={() => form.dispatchEvent(new Event("submit"))}
                                                    ^
49:          >
50:          {@html addItem(newTask ? "#000000" : "#999999")}
created dist/bundle.js in 1.8s

[2019-10-27 12:29:12] waiting for changes...

Seeing as Event is a global constructor, it should not give me a warning that Event is not defined.

Here is my rollup.config.js:

import svelte from "rollup-plugin-svelte";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import { terser } from "rollup-plugin-terser";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";
import html from "rollup-plugin-bundle-html";
import postcss from "rollup-plugin-postcss";
import babel from "rollup-plugin-babel";
import del from "rollup-plugin-delete";

const isProduction = process.env.MODE === "production";

export default {
    input: "src/index.js",
    output: {
        sourcemap: !isProduction,
        file: isProduction ? "dist/bundle-[hash].js" : "dist/bundle.js",
        name: "app",
        format: "iife"
    },
    plugins: [
        del({
            targets: "dist/bundle*"
        }),

        html({
            template: "src/index.html",
            dest: "dist",
            filename: "index.html"
        }),

        svelte({
            dev: !isProduction,
            css: css => {
                css.write(isProduction ? "dist/bundle-[hash].css" : "dist/bundle.css", !isProduction);
            }
        }),

        postcss({
            minimize: true,
            extensions: [".css"]
        }),

        resolve({
            browser: true,
            dedupe: importee => importee === "svelte" || importee.startsWith("svelte/")
        }),

        babel({
            extensions: [".js", ".mjs", ".html", ".svelte"]
        }),

        commonjs(),

        !isProduction && livereload({
            watch: "dist"
        }),

        !isProduction && serve({
            contentBase: "dist",
            port: 5000
        }),

        isProduction && terser(),
    ]
};
@Conduitry
Copy link
Member

Moving this to the svelte repo, as that's where these warnings actually are generated.

Adding Event to the list of common globals seems reasonable.

@Conduitry
Copy link
Member

Actually, it appears you can't transfer an issue between organizations (rollup -> sveltejs), which I suppose is a reasonable limitation.

@Conduitry
Copy link
Member

Closing in favor of sveltejs/svelte#3805.

@Joxtacy
Copy link
Author

Joxtacy commented Oct 27, 2019

@Conduitry Thanks! Sorry about placing this in the wrong repo.

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

No branches or pull requests

2 participants