typeit
typeit copied to clipboard
Error in dist/index.es.js during npm build
Hi, I get the following error when I run my Parcel build with 'npm run build' /Applications/MAMP/htdocs/erjanborren/node_modules/typeit/dist/index.es.js: Unexpected token: punc (.)
This is the call stack:
at Z.get (/Applications/MAMP/htdocs/erjanborren/node_modules/terser/dist/bundle.min.js:1:525) at Object.errorToJson (/Applications/MAMP/htdocs/erjanborren/node_modules/@parcel/utils/src/errorUtils.js:9:20) at Pipeline.process (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Pipeline.js:29:26) at async Object.run (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/worker.js:15:12) at async Bundler.loadAsset (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Bundler.js:577:19) at async /Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Bundler.js:610:13 at async Promise.all (index 1) at async Bundler.loadAsset (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Bundler.js:599:21) at async /Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Bundler.js:610:13 at async Promise.all (index 4) at async Bundler.loadAsset (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Bundler.js:599:21) at async Bundler.processAsset (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/Bundler.js:557:5) at async PromiseQueue._runJob (/Applications/MAMP/htdocs/erjanborren/node_modules/parcel-bundler/src/utils/PromiseQueue.js:48:7)
I don't get an error when i just do npm start, all typeit code runs fine then. I'm using Parcel 1.12.5 and typeit 8.8.4. Let me know if you need extra information. Thanks, Tom
Upon further review, I've found that the minification process of parcel is where the error occurs. It uses Terser for this and it breaks when trying to minify the index.es.js file. According to copilot it could have something to do with these shorthands: step.char?.innerText Parcel 1.12.5 uses Terser 3.17 and I couldn't get it to use a newer version.
Interesting. I've not seen this error before, and optional chaining has been supported in JavaScript for some time now. It does look like you're using a very old version of Parcel (it's at 2.12.0). I'd either see if you can upgrade the version in your project, or else import the UMD version of TypeIt:
import TypeIt from 'typeit/dist/typeit.umd.js';
Hey, I fixed it by turning off minimisation in Parcel 1 and doing it with a newer version of Terser after asset generation. In a newer project I was able to update Parcel to v2 and that fixed it too.
On Sun, Sep 15, 2024 at 9:34 PM Alex MacArthur @.***> wrote:
Interesting. I've not seen this error before, and optional chaining has been supported in JavaScript for some time now. It does look like you're using a very old version of Parcel (it's at 2.12.0). I'd either see if you can upgrade the version in your project, or else import the UMD version of TypeIt:
import TypeIt from 'typeit/dist/typeit.umd.js';
— Reply to this email directly, view it on GitHub https://github.com/alexmacarthur/typeit/issues/388#issuecomment-2351762987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5APIDR6E43YWPXIHNCJ43ZWXOKVAVCNFSM6AAAAABMOCAECGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJRG43DEOJYG4 . You are receiving this because you authored the thread.Message ID: @.***>