ritz078 / embed-js

🌻 A lightweight plugin to embed emojis, media, maps, tweets, code and more. ✨
https://codesandbox.io/s/Wp5OlNMn
MIT License
1.27k stars 89 forks source link

Import Error Gulp/Webpack Task #255

Closed AlexR1712 closed 7 years ago

AlexR1712 commented 7 years ago

Hello guys, I have the following error, when I try to import embedjs to my code and run gulp/webpack task not works, can anyone help me to for solve import error.

I'm using this line to import embedjs import EmbedJS from 'embed-js'; but get this:

`[10:37:01] Using gulpfile /var/www/html/domain.com/gulpfile.js
[10:37:01] Starting 'all'...
[10:37:01] Starting 'sass'...
[10:37:02] Finished 'sass' after 1.55 s
[10:37:02] Starting 'combine'...
[10:37:02] Finished 'combine' after 56 ms
[10:37:02] Starting 'webpack'...
[10:37:04] 
[10:37:04] Finished 'webpack' after 1.77 s
[10:37:04] Starting 'sass'...
[10:37:06] Finished 'sass' after 1.33 s
[10:37:06] Starting 'webpack'...
{ [Error: ./~/embed-js/src/index.js
Module parse failed: /var/www/html/domain.com/node_modules/embed-js/src/index.js Unexpected token (84:8)
You may need an appropriate loader to handle this file type.
|   }
| 
|   async render() {
|     const { input, target, inlineEmbed } = this.options
|     if (!isElementPresent(this.options)) {
 @ ./resources/assets/js/panel.js 12:0-31]
  message: './~/embed-js/src/index.js\nModule parse failed: /var/www/html/domain.com/node_modules/embed-js/src/index.js Unexpected token (84:8)\nYou may need an appropriate loader to handle this file type.\n|   }\n| \n|   async render() {\n|     const { input, target, inlineEmbed } = this.options\n|     if (!isElementPresent(this.options)) {\n @ ./resources/assets/js/panel.js 12:0-31',
  showStack: false,
  showProperties: true,
  plugin: 'webpack-stream',
  __safety: { toString: [Function: bound ] } }
`
ritz078 commented 7 years ago

Maybe its because you are importing a ES6 file without running it through babel. Try using

import EmbedJS from "embed-js/dist/index.js"
AlexR1712 commented 7 years ago

Thank you @ritz078 Now Its Working! :+1:

ritz078 commented 7 years ago

Great.