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

In build mode, umd modules having external react fail, but works in dev #2210

Closed
jide opened this issue Jan 11, 2017 · 2 comments
Closed

In build mode, umd modules having external react fail, but works in dev #2210

jide opened this issue Jan 11, 2017 · 2 comments

Comments

@jide
Copy link

jide commented Jan 11, 2017

Hello,

I have a project set up using JSPM 1.7. It imports several custom modules that have been built using webpack with external react as umd :

module.exports = {
  ...
  output: {
    ...
    libraryTarget: 'umd',
    library: 'react-video',
    umdNamedDefine: 'react-video'
  },
  ...
  externals: {
    react: 'umd react',
    'react-dom': 'umd react-dom'
  }
};

jspm.config.js looks like this :

SystemJS.config({
  packageConfigPaths: [
    'npm:@*/*.json',
    'npm:*.json',
    'github:*/*.json'
  ],
  map: {
    ...
    'react': 'npm:[email protected]',
    'react-dom': 'npm:[email protected]',
    'react-video': 'github:Synchronized-TV/react-video@master',
    ...
  },
  ...

When running in dev (I use jspm-server), the modules are correctly exported and react is resolved.

When using the build command though, it does not work. Without any change to jspm.config.js, I get this error on build :

Error: Multiple anonymous defines.

I edited jspm.config.js, and after that builds succeeds (but in dev this does not work) :

SystemJS.config({
  ...
  packages: {
    'github:Synchronized-TV/react-video@master': {
      'format': 'global'
    },
    ...

But when running the code, the react module required inside the webpack module is not found :

TypeError: Cannot read property 'PureComponent' of undefined

I tweaked jspm.config.js again like this :

SystemJS.config({
  ...
  packages: {
    'github:Synchronized-TV/react-video@master': {
      'format': 'global',
      map: {
        'react': 'npm:[email protected]',
        'react-dom': 'npm:[email protected]'
      }
    },
    ...

...but I get the same error :

capture d ecran 2017-01-11 a 18 37 57

Which is where react is passed to the webpack module :

capture d ecran 2017-01-11 a 18 40 13

Is there something I did wrong ?

@guybedford
Copy link
Member

This may be related to facebook/react#8392. Perhaps try that latest version of React and see if that fixes things?

@jide
Copy link
Author

jide commented Jan 13, 2017

Hmmmm unfortunately it did not work... For my own use case I decided to go back to pure webpack, with some tweaking to be able to remote load the module.

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

No branches or pull requests

2 participants