nwb icon indicating copy to clipboard operation
nwb copied to clipboard

Usage with SSR React projects.

Open haani104 opened this issue 6 years ago • 3 comments

This issue is a:

  • Question / support request

REPRO REPOS https://github.com/ctrlplusb/react-universally

Is the version of nwb you're using installed globally or locally? - Globally

➜  react-universally git:(master) ✗ node -v
v8.11.1
➜  react-universally git:(master) ✗ npm -v
6.1.0
➜  react-universally git:(master) ✗ nwb -v
v0.21.5

Hi, I have created a npm module (using nwb new react-component), which is published on npm and can be installed by typing npm i react-loading-button-check

The issue is whenever I am importing the button, i.e. import LoadingButton from 'react-loading-button-check' in any server side rendering(SSR) react project, I always get the below error

buttonstyle.css:1
(function (exports, require, module, __filename, __dirname) { .button-comp {
                                                              ^

SyntaxError: Unexpected token .
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/haani/learnspace/react-universally/node_modules/react-loading-button-check/lib/index.js:17:1)

However it runs fine when used with any other non SSR React projects.

I am tryig to build a React library that can also be used by SSR React projects. Please help/guide.

haani104 avatar Jun 24 '18 14:06 haani104

same issue here

lean avatar Jan 21 '19 15:01 lean

@lean If the above is a blocker for you, I suggest you look into other options for creating React library. Like this one https://github.com/transitive-bullshit/create-react-library

haani104 avatar Jan 21 '19 16:01 haani104

Yes, it is a blocker. So I will try your suggestion. Thanks

lean avatar Jan 21 '19 17:01 lean