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

[Help needed] Nuxt 3 support #119

Merged
merged 33 commits into from
Nov 12, 2022
Merged

Conversation

Redemption198
Copy link
Contributor

@Redemption198 Redemption198 commented May 19, 2022

This is my first module so probably something isn't correct, I ported the device module to Nuxt 3 by rewriting it from scratch using the old code and the module starter from CLI, it should behave like the old one.

What's missing:

  • Tests
  • Publication workflow
  • Nuxt 2/Bridge support (Marked as supported, needs to be tested)
    (^ I don't have experience with these ^)
  • New readme information

Also added docs to the module config parameters
@thoth3x
Copy link

thoth3x commented Jun 27, 2022

Hi,

When I pull your code the only thing that get pulled is README.md, package.json and LICENSE

Screenshot 2022-06-27 at 11 55 10

I've tried with:

npm install git+https://github.com/Redemption198/device-module#master

npm install nuxt-community/device-module#pull/119/head:master (and variations without the head part)

also pulled the original @nuxt/device and then tried git fetch origin pull/119/head:master in it

but all with the same result

Any idea how to get all files?

Thank you!

@Redemption198
Copy link
Contributor Author

Redemption198 commented Jun 27, 2022

Hi,

When I pull your code the only thing that get pulled is README.md, package.json and LICENSE

Screenshot 2022-06-27 at 11 55 10

I've tried with:

npm install git+https://github.com/Redemption198/device-module#master

npm install nuxt-community/device-module#pull/119/head:master (and variations without the head part)

also pulled the original @nuxt/device and then tried git fetch origin pull/119/head:master in it

but all with the same result

Any idea how to get all files?

Thank you!

Nothing appears because the module usually is built and uploaded to npm so the build files are ignored by Git. I built the module and temporarily included the build files, if you install it again it should work.

TypeScript autocomplete seems to not be working currently (inside the module playground it did) everything else should work fine.

Update: TypeScript autocomplete works with the latest commit.

@nathanchase
Copy link

Would love to see this merged in as a next branch. There is a need for the module to be production-ready for Nuxt 3.

@nathanchase
Copy link

nathanchase commented Sep 6, 2022

This module will need an update to work with Nuxt 3 rc-9 and above. Currently in 3.0.0-rc.9 it gives the following error:

WARN  Module device-module is disabled due to incompatibility issues:  [nuxt] Nuxt version `^3.0.0 || ^2.16.0` is required but currently using '3.0.0-rc.9'

This is due to nuxt/framework#7116

@Redemption198
Copy link
Contributor Author

This module will need an update to work with Nuxt 3 rc-9 and above. Currently in 3.0.0-rc.9 it gives the following error:

WARN  Module device-module is disabled due to incompatibility issues:  [nuxt] Nuxt version `^3.0.0 || ^2.16.0` is required but currently using '3.0.0-rc.9'

This is due to nuxt/framework#7116

Thanks for the solution, the module has been updated to RC9.

@robinscholz
Copy link

+1 for releasing this under a next branch

dist/runtime/plugin.mjs Outdated Show resolved Hide resolved
@TheAlexLichter
Copy link

Thank you for your PR! 🙏

Copy link

@TheAlexLichter TheAlexLichter left a comment

Choose a reason for hiding this comment

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

Left some remarks ☺️

dist/module.cjs Outdated
@@ -0,0 +1,5 @@
module.exports = function(...args) {

Choose a reason for hiding this comment

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

Any reason why you push the dist folder Ideally this will be auto-generated and only available on NPM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're correct, that was intentional because as requested here, people were trying to install it from GitHub. It wasn't included when I opened this PR, but 5 months passed and no one from this repository showed up so I temporarily included it.

Choose a reason for hiding this comment

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

Ahh, got it 👍🏻
Yes, that makes sense - alternatively feel free to publish a temp package so people can use that while the PR is pending 😋

@@ -1,12 +0,0 @@
const fetch = require('node-fetch')

Choose a reason for hiding this comment

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

Why removing the generation script here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly I have no idea, maybe it wasn't needed to make the module work so I forgot about it, I've restored it.

Choose a reason for hiding this comment

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

The idea was supposedly to have an easy way to generate the browser regexes so it isn't necessary to do it manually 😋

src/module.ts Outdated
name: 'device-module',
configKey: 'device',
compatibility: {
nuxt: '^3.0.0-rc.11 || ^2.16.0',

Choose a reason for hiding this comment

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

If it is compatible with previous RCs, I'd suggest to use a lower version (lowest compatible one)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lowered to RC5.

},
setup (options, nuxt) {
if (options.enabled) {
nuxt.options.runtimeConfig.public.device = defu(nuxt.options.runtimeConfig.public.device, {

Choose a reason for hiding this comment

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

Not necessary to merge options manually ☺️ You can skip that block

Copy link
Contributor Author

@Redemption198 Redemption198 Oct 17, 2022

Choose a reason for hiding this comment

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

Thanks I removed it, I put it because I saw it in other Nuxt modules, as I said in the PR description this is my first module so I don't have the experience and the guides aren't much beginner friendly.

Choose a reason for hiding this comment

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

More than understandable. Does/did the module author guide help you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It kinda did, maybe 5 months ago something was missing or wasn't explained clearly, I've checked it again and it seems fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to implement the tests, and noticed that the removal of the merge options prevents the plugin to access the module options.

Inside ./src/runtime/plugin.ts accessing useRuntimeConfig().public returns an empty object.

Copy link

@TheAlexLichter TheAlexLichter Oct 17, 2022

Choose a reason for hiding this comment

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

Ohh, sorry. My bad! Didn't read correctly and thought you merge the options themself, not the runtimeConfig.

So, ignore what I said and feel free to reintroduce the changes 🙈

@TheAlexLichter
Copy link

cc @danielroe, would really like to have your opinion on the PR too ☺️

@TheAlexLichter
Copy link

Regarding tests: I suppose that Nuxt's test-utils will come in handy - but I am not sure how easy it will be to "fake" the user agent for tests 🙈

@Redemption198
Copy link
Contributor Author

Redemption198 commented Oct 17, 2022

Regarding tests: I suppose that Nuxt's test-utils will come in handy - but I am not sure how easy it will be to "fake" the user agent for tests see_no_evil

I found a way to recreate the old tests with Nuxt test utils, it isn't elegant but seems to be working.

@TheAlexLichter
Copy link

LGTM! cc @dotneet

@dotneet
Copy link
Collaborator

dotneet commented Nov 12, 2022

@Redemption198 Thank you for your great work!

@dotneet dotneet merged commit b0018b4 into nuxt-modules:master Nov 12, 2022
@dotneet
Copy link
Collaborator

dotneet commented Nov 12, 2022

@Redemption198 3.0.0 has been released to npm!

@Redemption198
Copy link
Contributor Author

@Redemption198 3.0.0 has been released to npm!

Nice!

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.

7 participants