michelson / dante2

A complete rewrite of dante editor in draft-js
https://michelson.github.io/dante2/
Other
910 stars 121 forks source link

export.default not working #73

Closed LazerJesus closed 6 years ago

LazerJesus commented 6 years ago

Problem

importing Dante2 into my storybook is not working.

Code

  importDependencies() {
    const imports = [
      require("Dante2/es/index.js")
      // ...
    ]

    Promise.all(imports)
      .then(([Dante2]) => {
        console.log(Dante2)
      })
  }

Errors

Chrome Console

dante_editor.js:977 
Uncaught (in promise) TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
    at Object.<anonymous> (VM2500 0.bundle.js:28743)
    at Object.Array.concat.exports.__esModule (VM2500 0.bundle.js:28744)
    at __webpack_require__ (VM2448 preview.bundle.js:708)

Terminal output

WARNING in ../src/node_modules/Dante2/es/components/dante.js
258:61-72 "export 'default' (imported as 'DanteEditor') was not found in './dante_editor.js'
 @ ../src/node_modules/Dante2/es/components/dante.js
 @ ../src/node_modules/Dante2/es/index.js
 @ ../src/imports/components/Stepper/inputs/DanteTextarea.jsx
 @ ./stories/ArticleEdit/Dante.stories.js
 @ ./stories/ArticleEdit/index.js
 @ ./stories/index.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js (webpack)-hot-middleware/client.js?reload=true ./.storybook/config.js

WARNING in ../src/node_modules/Dante2/es/index.js
6:9-14 "export 'default' (imported as 'Dante') was not found in './components/dante'
 @ ../src/node_modules/Dante2/es/index.js
 @ ../src/imports/components/Stepper/inputs/DanteTextarea.jsx
 @ ./stories/ArticleEdit/Dante.stories.js
 @ ./stories/ArticleEdit/index.js
 @ ./stories/index.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js (webpack)-hot-middleware/client.js?reload=true ./.storybook/config.js

WARNING in ../src/node_modules/Dante2/es/index.js
7:15-26 "export 'default' (imported as 'DanteEditor') was not found in './components/dante_editor'
 @ ../src/node_modules/Dante2/es/index.js
 @ ../src/imports/components/Stepper/inputs/DanteTextarea.jsx
 @ ./stories/ArticleEdit/Dante.stories.js
 @ ./stories/ArticleEdit/index.js
 @ ./stories/index.js
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js (webpack)-hot-middleware/client.js?reload=true ./.storybook/config.js
Storybook started on => http://localhost:6006/
LazerJesus commented 6 years ago

when trying to start in meteor:

=> Exited with code: 1
 packages/modules.js:41241
 import Dante from './components/dante';
 ^^^^^^

 SyntaxError: Unexpected reserved word
     at Object.exports.runInThisContext (vm.js:53:16)

// edit: above only occurs when require("Dante2/es/index.js") require("Dante2)" does not throw

michelson commented 6 years ago

can you use import instead require ? it seems mixing require & import is not valid

LazerJesus commented 6 years ago

same issue. but Dante2/lib/index.js works with both import and require. any objections to the use of /lib/?

zcmgyu commented 6 years ago

https://github.com/michelson/dante2-tests

Dante2 0.4.0 works for me.