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

ES6 import is wrong? #127

Open
PierBover opened this issue Jun 23, 2021 · 5 comments
Open

ES6 import is wrong? #127

PierBover opened this issue Jun 23, 2021 · 5 comments

Comments

@PierBover
Copy link

In Node, this doesn't work:

import * as Vibrant from 'node-vibrant'

I get the error:

TypeError: Vibrant.from is not a function

Instead I'm using the regular import which works as expected:

import Vibrant from 'node-vibrant'

Do you want me to make a PR to fix the docs?

@bitdom8
Copy link

bitdom8 commented Sep 18, 2021

Hi @PierBover , how have you managed to get it working w/ ES6?

@PierBover
Copy link
Author

@bitdom8 import it like this:

import Vibrant from 'node-vibrant';

And then use it like this:

const colors = await Vibrant.from(filePath).getPalette();

@bitdom8
Copy link

bitdom8 commented Sep 19, 2021

Thanks @PierBover . It works great with :)))

pnpm run dev

however, when following is done, no use:(;

pnpm run build 
pnpm run preview

here is my dependencies:
"devDependencies": {
"@sveltejs/kit": "next",
"@types/cookie": "^0.4.0",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-svelte3": "^3.2.0",
"install": "^0.13.0",
"prettier": "~2.2.1",
"prettier-plugin-svelte": "^2.2.0",
"sass": "^1.41.0",
"svelte": "^3.34.0",
"svelte-check": "^2.0.0",
"svelte-preprocess": "^4.0.0",
"tslib": "^2.0.0",
"typescript": "^4.0.0"
},
"type": "module",
"dependencies": {
"@fontsource/fira-mono": "^4.2.2",
"@lukeed/uuid": "^2.0.0",
"cookie": "^0.4.1",
"filepond": "^4.29.0",
"filepond-plugin-image-exif-orientation": "^1.0.11",
"filepond-plugin-image-preview": "^4.6.8",
"fuse.js": "^6.4.6",
"nanoid": "^3.1.25",
"node-vibrant": "3.1.6",
"simple-svelte-autocomplete": "^2.2.3",
"svelte-emoji-selector": "^1.0.1",
"svelte-i18n": "^3.3.10"
}

Even change <script lang="ts"> to <script> and install worker-load, no use

@bitdom8
Copy link

bitdom8 commented Sep 19, 2021

The problem in this build file with vite bunderler:

__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Yp,"__esModule",{value:!0});var Yd=Hd(lc),Wd=zd,Xd=function(){function e(e,a){void 0===a&&(a={}),this._src=e,this._opts=a,this._opts.filters=Wd(Yd.default.DefaultOpts.filters)}return e.prototype.maxColorCount=function(e){return this._opts.colorCount=e,this},e.prototype.maxDimension=function(e){return this._opts.maxDimension=e,this},e.prot

so het this error:

vendor-40bcc9fd.js:30 Uncaught (in promise) TypeError: Cannot read property 'filters' of undefined

the q is how can we define filters' preceded value?

@bradyj04
Copy link

const colors = await Vibrant.from(filePath).getPalette();

I get the error "import not found: default" I think because it has no set default to import, but if I use import * as Vibrant from /path/, then I get the same error from the beginning of the thread, any idea how I could fix this?

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

3 participants