Skip to content

Uncaught ReferenceError: internal is not defined … #80

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

Closed
ha-douken opened this issue Nov 8, 2019 · 3 comments
Closed

Uncaught ReferenceError: internal is not defined … #80

ha-douken opened this issue Nov 8, 2019 · 3 comments

Comments

@ha-douken
Copy link

rollup.config.js

module.exports = {
  input: "comp.svelte",
  output: { file: "comp.js", format: "iife" },
  plugins: [ svelte() ]
}

comp.svelte
<script> console.log("Hello World") </script>

output in browser console
Uncaught ReferenceError: internal is not defined at comp.js

comp.js

(function (internal) {
  'use strict';

  /* comp.svelte generated by Svelte v3.12.1 */

  function create_fragment(ctx) {
  	return {
  		c: internal.noop,
  		m: internal.noop,
  		p: internal.noop,
  		i: internal.noop,
  		o: internal.noop,
  		d: internal.noop
  	};
  }

  function instance($$self) {
  	console.log("Hello World");

  	return {};
  }

  class Comp extends internal.SvelteComponent {
  	constructor(options) {
  		super();
  		internal.init(this, options, instance, create_fragment, internal.safe_not_equal, []);
  	}
  }

  return Comp;

}(internal));
@ha-douken
Copy link
Author

ha-douken commented Nov 8, 2019

Doing this with svelte-cli produces a file that works fine in the browser.
npx svelte-cli compile --format iife comp.svelte > comp.js

@Conduitry
Copy link
Member

You need rollup-plugin-node-resolve. See #54. svelte-cli has been deprecated for a while, and would result in compiling as Svelte v2 components, not Svelte v3 components.

@ha-douken
Copy link
Author

ha-douken commented Nov 17, 2019

Thanks, but now I get an error Comp is not defined when I want to instantiate the component after loading it.

<!doctype html>
<script defer src=/comp.js></script>
<script type=module>
new Comp({ target: document.body })
</script>

When compiling to iife using the vue-cli this works.

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