preline icon indicating copy to clipboard operation
preline copied to clipboard

Build failed on astro.build

Open alec-c4 opened this issue 3 years ago • 5 comments

Hey! Thanks a lot for your work! I'd like to ask you for help - I've added preline to my astro-powered app, but it fails with error

ReferenceError: self is not defined
    at Object.<anonymous> (/Users/alec/Code/Internal/Asgard Company/asgard_company_landing/node_modules/preline/dist/preline.js:2:224)
    at Module._compile (node:internal/modules/cjs/loader:1112:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:834:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
    at async nodeImport (file:///Users/alec/Code/Internal/Asgard%20Company/asgard_company_landing/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:53516:21)

Node.js v18.4.0
make: *** [dev] Error 1

when I use import('preline'). How to fix it?

alec-c4 avatar Oct 19 '22 21:10 alec-c4

Hey Alexey, hope the issue has been resolved - apologize for such a delayed reply.

Our team tested out Preline UI with Astro and seems everything is working fine. In addition, we have recently added Installation Guides for Astro here https://preline.co/docs/frameworks-astro.html

Please let us know the status of the issue. Thanks!

jahaganiev avatar Dec 09 '22 22:12 jahaganiev

Hey, @jahaganiev! Thanks a lot for your response, but there are some things i've found when tried to add preline to astro.

  1. I've moved import preline from "preline/plugin.js"; to astro.config.mjs
  2. It is incorrect path ./assets/vendor/preline/dist/preline.js here
// Layout.astro
<script is:inline src="./assets/vendor/preline/dist/preline.js"></script>

and i've changed to

<script is:inline src="node_modules/preline/dist/preline.js"></script>

and it works, but it looks ugly.

alec-c4 avatar Dec 10 '22 10:12 alec-c4

Hey @alec-c4 @jahaganiev have got the same issue here, docs aren't accurate. Your workaround above may not work in production btw

ddlaws0n avatar Dec 10 '22 15:12 ddlaws0n

There are still errors with using Astro with TypeScript, but it will be resolved when #28 is completed.

dereknex avatar Dec 14 '22 03:12 dereknex

There are still errors with using Astro with TypeScript, but it will be resolved when #28 is completed.

Noted, thanks for sharing!

jahaganiev avatar Dec 21 '22 23:12 jahaganiev

Hey @alec-c4 - we've added a backlink to our docs for this workaround solution. Thanks!

jahaganiev avatar Apr 03 '24 23:04 jahaganiev