Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

PropTypes not longer works? #321

Closed
bradennapier opened this issue Mar 9, 2017 · 4 comments
Closed

PropTypes not longer works? #321

bradennapier opened this issue Mar 9, 2017 · 4 comments
Assignees
Milestone

Comments

@bradennapier
Copy link

bradennapier commented Mar 9, 2017

I updated and now I cant seem to use ProPTypes?

import React, { PropTypes } from 'react';

...

HTML.propTypes = {
  title: PropTypes.string.isRequired,
  description: PropTypes.string.isRequired,
  appBodyString: PropTypes.string,
  headerElements: PropTypes.node,
  bodyElements: PropTypes.node,
};

/home/ubuntu/workspace/build/server/webpack:/shared/components/HTML/index.js:61
  title: PropTypes.string.isRequired,
         ^
TypeError: Cannot read property 'string' of undefined
@bradennapier
Copy link
Author

bradennapier commented Mar 9, 2017

the only way for this to even work anymore is to send the alias directly at /dist/index.js or else all types of other errors and problems arise with untranspiled code... but targeting /dist/index.js directly to fit this now fails to work with PropTypes using the standard import methods.

import React from 'react';

const { PropTypes } = React

this works fine but now every package that uses react has to be modified to do it this way which kind of defeats the entire purpose of this, no?

@bradennapier
Copy link
Author

bradennapier commented Mar 9, 2017

If you do not alias directly to /dist/preact-compat.js ( i see you changed that from .index which breaks the previous working option) then it does not work at all anymore... however you can not add that file this way when using react-dom otherwise that doesnt work


WARNING in ./server/middleware/reactApplication/ServerHTML.js
24:9-17 "export 'Children' was not found in 'react'

WARNING in ./server/middleware/reactApplication/ServerHTML.js
135:19-28 "export 'PropTypes' was not found in 'react'

WARNING in ./server/middleware/reactApplication/ServerHTML.js
136:11-20 "export 'PropTypes' was not found in 'react'

WARNING in ./server/middleware/reactApplication/ServerHTML.js
137:22-31 "export 'PropTypes' was not found in 'react'

WARNING in ./server/middleware/reactApplication/ServerHTML.js
140:10-19 "export 'PropTypes' was not found in 'react'

WARNING in ./server/middleware/reactApplication/ServerHTML.js
141:9-18 "export 'PropTypes' was not found in 'react'

WARNING in ./server/middleware/reactApplication/ServerHTML.js
142:18-27 "export 'PropTypes' was not found in 'react'

WARNING in ./shared/components/HTML/index.js
243:9-18 "export 'PropTypes' was not found in 'react'

WARNING in ./shared/components/HTML/index.js
244:15-24 "export 'PropTypes' was not found in 'react'

WARNING in ./shared/components/HTML/index.js
245:17-26 "export 'PropTypes' was not found in 'react'

WARNING in ./shared/components/HTML/index.js
246:18-27 "export 'PropTypes' was not found in 'react'

WARNING in ./shared/components/HTML/index.js
247:16-25 "export 'PropTypes' was not found in 'react'

that is when my alias is { 'react': 'preact-compat', 'react-dom': 'preact-compat' }

If I change 'react' to { 'react': 'preact-compat/dist/preact-compat.js' } then most of those errors go away but if I set react-dom to that then it breaks again but if i set react-dom to just preact-compat then I can not get render anymore so this is simply not really compatible out of the box with webpack 2 yet?

It seems that if i add

"_moduleAliases": {
    "react": "./node_modules/preact-compat/dist/preact-compat.es.js",
    "react-dom": "./node_modules/preact-compat/dist/preact-compat.es.js"
  }

to my package.json it resolves the issues.

@koellcode
Copy link

Same problem here since v3.14.0. v3.13.1 works pretty well.

@developit
Copy link
Member

developit commented Mar 9, 2017

@koellcode @bradennapier yikes! looks like something must have gone wrong with the build, which we changed here. Will fix this morning.

I believe this repro is hitting the same issue.

@developit developit self-assigned this Mar 9, 2017
@developit developit added this to the 3.14.1 milestone Mar 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants