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

chore: add index.ts to module starter #279

Closed
wants to merge 1 commit into from
Closed

Conversation

Atinux
Copy link
Member

@Atinux Atinux commented Mar 3, 2023

Explain that module authors can expose utils outside of Nuxt context for end users.

Actually I believe this does not work at all 🤔

  • package exports:

    starter/package.json

    Lines 8 to 14 in 358482c

    ".": {
    "types": "./dist/types.d.ts",
    "import": "./dist/module.mjs",
    "require": "./dist/module.cjs"
    }
    },
    "main": "./dist/module.cjs",

When running npm run prepack:
CleanShot 2023-03-03 at 11 25 19@2x

@codesandbox
Copy link

codesandbox bot commented Mar 3, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@Atinux Atinux requested review from danielroe and pi0 March 3, 2023 10:26
@Atinux Atinux changed the title chore: add index.ts in module starter chore: add index.ts to module starter Mar 3, 2023
@Tahul
Copy link
Contributor

Tahul commented Mar 6, 2023

Few context for this:

Few issues I remember from exporting your module utils from the same path as your defineNuxtModule:

  • These utils will have to be server/build time only, because the file will inevitably ship @nuxt/kit
  • If that file happen to be imported in a jiti context, @nuxt/kit will be inlined with the jiti(path)
    • (not sure if this one is still true)

What I usually do from my modules is a /utils export, or exporting my module from /nuxt or /module

Copy link
Member Author

Atinux commented Mar 15, 2023

Thank you @Tahul

It just seems a black box where no one as a simple answer to this. Will just close this issue and hope that no one will have to expose utils outside of the module

@Atinux Atinux closed this Mar 15, 2023
@Atinux Atinux deleted the chore/module-utils branch March 15, 2023 10:40
@danielroe
Copy link
Member

All imports meant to be imported within the user's Vue app should be in the runtime directory instead and exposed with a subpath export or directly through nuxt core utils like addImportsDir, addComponent, etc. Exports from index.ts are only meant to be used in your nuxt.config or otherwise in the build environment.

@pi0
Copy link
Member

pi0 commented Mar 15, 2023

I have opened #292 to continue on this discussion.

The module structure is intentionally opened to allow exposure to other integrations. Today, it is only possible via aliases for runtime and a mixed output for build time utils (via dist/module.*) shared between modules.

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.

None yet

4 participants