DEV Community

Discussion on: From classes to plain objects and pure functions

smalluban profile image
Dominik Lubański Author

My code is not fully working example ;) It's a most important part of the file. You still need to import the library. If you use some kind of bundler you can use this:

import { define } from 'hybrids';

If you want "pure" JS solution, you can use ES modules:

<script type="module">
  import { define } from '';

  const MyElement = {
    firstName: 'Dominik',
    lastName: 'Lubański',
    fullName: {
      get: ({ firstName, lastName }) => `${firstName} ${lastName}`,

  define('my-element', MyElement);

Or for older browsers support:

<script src=""></script>
  var define = window.hybrids.define;


Read more in Getting Started section of the library documentation.