Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Using preact-compat with nwb #246

Closed
2 of 4 tasks
quentin-sommer opened this issue Jan 25, 2017 · 3 comments
Closed
2 of 4 tasks

Using preact-compat with nwb #246

quentin-sommer opened this issue Jan 25, 2017 · 3 comments
Labels

Comments

@quentin-sommer
Copy link

  • Bug report
  • Feature request
  • Question / support request
  • Other

nwb is installed globally
node : 7.4.0
npm : 4.1.1
nwb: 0.15.2

node_modules :

├── nwb@0.15.3
├── preact@7.2.0
├── preact-compat@3.11.0
└── semantic-ui-react@0.64.4

How can i use preact-compat with nwb ? it works fine in development using this in nwb.config.js:

module.exports = {
  type: 'preact-app',
  webpack: {
    aliases: {
      'react': 'preact-compat',
      'react-dom': 'preact-compat'
    }
  }
}

but at build it yields this error:

> nwb build-preact-app

✔ Cleaning app
✖ Building Preact app

Failed to compile with 1 error.

ERROR  in vendor.4acb2e33.js from UglifyJs
SyntaxError: Unexpected token: punc ()) [./~/preact-compat/src/index.js:34,0][vendor.4acb2e33.js:6023,24]
@insin
Copy link
Owner

insin commented Jan 25, 2017

It's already configured for Preact apps by default so you can reuse existing React components without any config, so try removing your webpack.aliases config.

This default setup is currently only mentioned in the Quick Development guide, so I need to document it for nwb too.

The error is caused by preact-compat having a module entry in its package.json which results in Webpack 2 pulling in some untranspiled ES6 which UglifyJS can't handle (see #244).

@insin insin added the support label Jan 25, 2017
@quentin-sommer
Copy link
Author

Seems like it's even better than I thought! Thanks for this project, by the way. It's exactly what I was looking for and it's been a pleasure to use up to now, I can edit the doc if you want!

@insin
Copy link
Owner

insin commented Jan 25, 2017

Thanks, and enjoy 😋

Closing in favour of #247, which contains actionable outcomes from this issue - I hadn't thought to add a config hint for this case, which could have told you this was already handled when you configured these aliases yourself.

@insin insin closed this as completed Jan 25, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants