FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Use dynamic import in hooks for type module projects by frederikbosch · Pull Request #5084 · ionic-team/ionic-cli · GitHub

Repository navigation

Use dynamic import in hooks for type module projects - #5084

Open
frederikbosch wants to merge 1 commit into
ionic-team:developfrom
frederikbosch:patch-1
Open

frederikbosch wants to merge 1 commit into
ionic-team:developfrom
frederikbosch:patch-1

Conversation

frederikbosch commented Mar 19, 2024 •
edited
Loading

Copy link
Copy Markdown

When using ionic + vue, the hooks serve:before scripts defined in ionic.config.json cannot run.

ionic.config.json

  "hooks": {
    "serve:before": ["./scripts/serve-before.js"]
  }

serve-before.js:

export default async function (ctx) {
}

This setup generates the following error:

[ERROR] An error occurred while running an Ionic CLI hook defined in ./ionic.config.json.
        
        Hook: serve:before
        File: /srv/libraries/app-ionic/scripts/install-custom.js
        
        Error [ERR_REQUIRE_ESM]: require() of ES Module /srv/libraries/app-ionic/scripts/serve-before.js from
        /srv/libraries/app-ionic/node_modules/@ionic/cli/lib/hooks.js not supported.
        Instead change the require of install-custom.js in
        /srv/libraries/app-ionic/node_modules/@ionic/cli/lib/hooks.js to a dynamic import() which is available in
        all CommonJS modules.
        at ServeBeforeHook.loadHookFn (/srv/libraries/app-ionic/node_modules/@ionic/cli/lib/hooks.js:73:24)

Switching back to require and module.exports style nodejs is not possible, because of the project type in the package.json.

"type": "module",

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL