Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

debug.js imports itself when relative imports are prioritised #959

Closed
wassname opened this issue Nov 30, 2016 · 4 comments
Closed

debug.js imports itself when relative imports are prioritised #959

wassname opened this issue Nov 30, 2016 · 4 comments
Labels

Comments

@wassname
Copy link
Contributor

wassname commented Nov 30, 2016

Steps

  1. compile a react project which has import { Input, Menu, Segment } from "semantic-ui-react"
  2. run it in the browser

Expected Result

No errors

Actual Result

debug.js:38Uncaught TypeError: _debug.enable is not a function

This is because when the debug.js file runs require("debug") it import itself, not the node debug module. I recommend renaming it to 'startDebug.js' to avoid recursive imports when relative importing is enabled and prioritied.

Version

0.61.7

Testcase

N/A

@wassname
Copy link
Contributor Author

P.S. the workaround is to set the webpack config:

module.exports = {
  resolve:{
    "debug": "debug/browser.js"
  }
}

@levithomason
Copy link
Member

levithomason commented Nov 30, 2016

The debug module defines the browser field in their package.json:

{
  "browser": "./browser.js",
}

This is used by webpack to automatically require the browser build making the resolve config unnecessary. We also use debug both in dev and production mode on the doc site without no errors.

This leads me to believe it is something unique to the setup where you're seeing this. What version of Webpack are you using and how are you setting your environment?

@noah79
Copy link

noah79 commented Apr 7, 2017

I have the same problem. I'm in webpack 2 and typescript 2.2.1.

@levithomason
Copy link
Member

levithomason commented Apr 7, 2017

http://react.semantic-ui.com is powered by webpack 2 without issues. You can review our webpack.config.js in this repo to see how we're doing things.

You can also see an upcoming doc update showing webpack 2 usage in this PR #1497.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants