lovetodream / capacitor-plugin-siri-shortcuts

Capacitor Plugin for Siri Shortcuts
MIT License
18 stars 6 forks source link

CommonJS entrypoint #43

Closed RobSchilderr closed 2 years ago

RobSchilderr commented 2 years ago

Hey, what a great idea this is! Will you update this to Capacitor v4? Cant wait to try it out and see all the new iOS 16 possibilities

lovetodream commented 2 years ago

Hey, thanks. The newest version of the plugin should already work with v4. Did you try it out already? If it doesn't work, I'd appreciate if you can attach the error logs.

RobSchilderr commented 2 years ago

I will check it out tomorrow! Thanks so much. If it works like I think it could work for my app, I'll sponsor this project

lovetodream commented 2 years ago

Let me know if something doesn't work or if you have any additional feature requests

RobSchilderr commented 2 years ago

Let me know if something doesn't work or if you have any additional feature requests

Sure thing, Timo! I'm getting an error when I try to build with NextJS. I'll try to explain it:

Describe the bug My build is failing if the following import { SiriShortcuts } from 'capacitor-plugin-siri-shorts is defined somewhere in the code.

The error is the following:

triggerUncaughtException(err, true /* fromPromise */);
            ^
ReferenceError: capacitorExports is not defined
    at Object.<anonymous> (/node_modules/capacitor-plugin-siri-shorts/dist/plugin.js:12:8)

I am using the NextJS's next build command to the run build.

To Reproduce Steps to reproduce the behavior:

  1. Build a project with NextJS and Capacitor
  2. Follow installation steps of capacitor-plugin-siri-shorts
  3. Run yarn build again

Possible solution

Change "main": "dist/plugin.js" to "main": "dist/plugin.cjs.js" in the package.json

I was looking for a solution for us this morning. I must confess that I am unfamiliar with Swift or capacitor plugins. But if I made this change, I was able to get next build to work. It's possible that it's an incorrect solution, so proceed with caution. I tried this after reading about a related issue.

Please let me know if this is the correct solution or if you require any additional information! I haven't gotten the plugin to work yet, because I can't build the code yet in Appflow.

Thanks so much for replying @lovetodream

lovetodream commented 2 years ago

Even through I cannot reproduce your issue, I've found out that the boilerplate for the package.json for capacitor plugins has changed to the cjs-way you're suggesting https://github.com/ionic-team/create-capacitor-plugin/blob/main/assets/plugin-template/package.json.mustache#L5 I'll release an update including the changes as a breaking change with v3.0.0 of the plugin, because I do not know how this affects existing projects.

RobSchilderr commented 2 years ago

Even through I cannot reproduce your issue, I've found out that the boilerplate for the package.json for capacitor plugins has changed to the cjs-way you're suggesting https://github.com/ionic-team/create-capacitor-plugin/blob/main/assets/plugin-template/package.json.mustache#L5 I'll release an update including the changes as a breaking change with v3.0.0 of the plugin, because I do not know how this affects existing projects.

Cheers man! Will let you know after the update how things go.