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

fix: Custom drivers failed on build #2193

Merged
merged 6 commits into from Aug 24, 2023

Conversation

shareable-vision
Copy link
Contributor

πŸ”— Linked issue

Issue #2096 (Custom drivers failed to build)

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Resolves #2096 so that Nuxt Content builds with support for custom drivers:

  • modified getMountDriver() in src/utils.ts to "change the require [statement] to a dynamic import()".
  • modified setup() in src/module.ts to await getMountDriver().
  • modified tsconfig.json to avoid TS2705 error: "A dynamic import call in ES5/ES3 requires the Promise constructor. Make sure you have a declaration for the Promise constructor or include ES2015 in your --lib option."

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

…tatement] to a dynamic import()".

Modify `setup()` in `src/module.ts` to await `getMountDriver()`.
Modify `tsconfig.json` to avoid TS2705 error: "A dynamic import call in ES5/ES3 requires the Promise constructor. Make sure you have a declaration for the Promise constructor or include ES2015 in your --lib option."
@netlify
Copy link

netlify bot commented Jul 24, 2023

βœ… Deploy Preview for nuxt-content ready!

Name Link
πŸ”¨ Latest commit 50b8bc1
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt-content/deploys/64e754e365bbf70008e29660
😎 Deploy Preview https://deploy-preview-2193--nuxt-content.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@farnabaz
Copy link
Member

Thanks for the PR,
Do you mind adding a simple test for it?
Maybe adding a new fixture for custom driver with simple tests in it would be good approach

@shareable-vision
Copy link
Contributor Author

Sorry for the delay. Yes, if creating a new fixture is simply creating a small demo application that is using a custom driver, I can do that.

I will merge the latest updates with the PR branch and add the fixture.

shareable-vision and others added 2 commits July 30, 2023 13:22
Reproduce:
```
pnpm install
npm run build
npm run dev:fixtures custom-driver
```
@shareable-vision
Copy link
Contributor Author

shareable-vision commented Jul 31, 2023

Created /test/fixtures/custom-driver.

Uses a locally defined github.mjs driver to pull content from nuxt/content repo at /test/fixtures/basic/content.

( I know that 'github' is already a supported driver that does not require a custom definition, but this was the simplest test )

@shareable-vision
Copy link
Contributor Author

shareable-vision commented Jul 31, 2023

I'm re-reading your request:

Maybe adding a new fixture for custom driver with simple tests in it would be good approach

Following the same pattern as the other fixtures, I created a custom-driver directory including a mini application with a Nuxt config that uses a custom driver definition.

@shareable-vision
Copy link
Contributor Author

I wrote a custom-driver.test.ts that simply tests if the fixture builds successfully.

Copy link
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ❀️

@farnabaz farnabaz merged commit 5002a37 into nuxt:main Aug 24, 2023
7 checks passed
@farnabaz farnabaz mentioned this pull request Aug 29, 2023
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.

Custom drivers failed on build
2 participants