question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add doc for sjs-bundler/module users

See original GitHub issue

Due to https://github.com/scala-js/scala-js/issues/2797 I cannot support both script-style (@JSName/@JSGlobal) and module-style (@JSImport) in this library.

I’ll keep it as script style for now, probably until SJS 1.0 is released.

In order to use scalajs-react with scalajs-bundler / module-style, the following webpack config is required:

module: {
  rules: [{
      test: require.resolve('react'),
      use: [{loader: 'expose-loader', options: 'React'}]
    }, {
      test: require.resolve('react-dom'),
      use: [{loader: 'expose-loader', options: 'ReactDOM'}]
    }],
  },
  entry: ['react', 'react-dom'],
}

There’s also a demo repo where I have this working with some other features as I experiment with webpack + Scala.JS: https://github.com/japgolly/misc/tree/webpack

Put all this ↑ info in the docs for scalajs-react 1.0.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
dispaltcommented, Mar 17, 2017

You can also do something like… I haven’t done it in a while, so it’s probably close to correct. If you don’t want to mess with webpack configs (which breaks the best feature, enableReloadWorkflow, imo).

@JSImport("React", JSImport.Default)
@js.native
object RStub extends js.Object

def main(): Unit = {
  global.React = RStub
}

This would not be in the library itself, but in the app

1reaction
japgollycommented, Apr 26, 2017

Closed via 5169e79a83f7c959f29194f2071f2063ba7846c1 Not huge but it’ll have to do

Read more comments on GitHub >

github_iconTop Results From Across the Web

Facades should be able to support all values of ModuleKind
Put @JSImport on my facades and force users to use CommonJSModule and ... Add doc for sjs-bundler/module users japgolly/scalajs-react#343.
Read more >
How to add Document with Custom ID to firestore
To use a custom ID you need to use .set , rather than .add. This creates a document with the ID "LA":
Read more >
How to Build the Best User Documentation (New Guide) | Blog
Have a product or service that needs user documentation? Here are some simple tips on how to build the best documentation for consumers....
Read more >
Firebase V9 Firestore Add Document Data – addDoc()
Learn how to add data as document to Firebase version 9 Cloud Firestore database using addDoc(), getFirestore() and collection() methods.
Read more >
Getting Started with Firebase 9 #5 - YouTube
Hey all, in this Firebase 9 tutorial I'll show you how to add new documents (save them) and also how to delete documents...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found