How to use require() for internal ou external lib node_modules custom block?

Created on 7 July 2020, over 4 years ago
Updated 17 January 2023, almost 2 years ago

I created a hello.es6.js and I imported it in the index.es6.js, but throw an error in my browser "Uncaught ReferenceError: require is not defined", I built with npm run-script build hello.es6.js to hello.js and it's work and put js/hello.js: {} in .libraries.yml too

and another question, how to use external lib like slick slider in node_modules?

Follow my files:

Hello.e6.js - Throw error in browser - Uncaught ReferenceError: exports is not defined(My files are transpile)

class Hello extends Component {
  render() {
    return (
      <div>hello</div>
    );
  }
}


export default Hello;

Index.es6.js - Uncaught ReferenceError: require is not defined(My files are transpile)

import Hello from './hello'

name-test .libraries.yml

js/hello.js: {}
💬 Support request
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇧🇷Brazil bdias.ti

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024