Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design committed Aug 30, 2023
1 parent c39547c commit 52abdea
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 22 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
"prepublishOnly": "base prepublishOnly",
"test": "base test"
},
"resolutions": {
"nuxi": "3.6.5"
},
"dependencies": {
"@babel/core": "^7.10.2",
"@dword-design/suppress-babel-register-esm-warning": "^1.1.10",
"@nuxt/kit": "^3.7.0",
"@rollup/plugin-babel": "^6.0.3",
"@vitejs/plugin-vue": "^4.2.3",
"@vue/compiler-sfc": "^3.3.4",
Expand Down
94 changes: 94 additions & 0 deletions src/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,100 @@ export default tester(
await kill(nuxt.pid)
}
},
async 'dev NITRO_PORT env variable'() {
await fs.outputFile(
'pages/index.vue',
endent`
<template>
<div class="foo">Hello world</div>
</template>
`,
)

const nuxt = execa(resolver.resolve('./cli.js'), ['dev'], {
env: { NITRO_PORT: 4000 },
})
try {
await nuxtDevReady(4000)
await this.page.goto('http://localhost:4000')
expect(await this.page.$eval('.foo', div => div.textContent)).toEqual(
'Hello world',
)
} finally {
await kill(nuxt.pid)
}
},
async 'dev NUXT_PORT env variable'() {
await fs.outputFile(
'pages/index.vue',
endent`
<template>
<div class="foo">Hello world</div>
</template>
`,
)

const nuxt = execa(resolver.resolve('./cli.js'), ['dev'], {
env: { NUXT_PORT: 4000 },
})
try {
await nuxtDevReady(4000)
await this.page.goto('http://localhost:4000')
expect(await this.page.$eval('.foo', div => div.textContent)).toEqual(
'Hello world',
)
} finally {
await kill(nuxt.pid)
}
},
async 'dev PORT env variable'() {
await fs.outputFile(
'pages/index.vue',
endent`
<template>
<div class="foo">Hello world</div>
</template>
`,
)

const nuxt = execa(resolver.resolve('./cli.js'), ['dev'], {
env: { PORT: 4000 },
})
try {
await nuxtDevReady(4000)
await this.page.goto('http://localhost:4000')
expect(await this.page.$eval('.foo', div => div.textContent)).toEqual(
'Hello world',
)
} finally {
await kill(nuxt.pid)
}
},
async 'dev port config variable'() {
await outputFiles({
'nuxt.config.js': endent`
export default {
devServer: { port: 4000 },
}
`,
'pages/index.vue': endent`
<template>
<div class="foo">Hello world</div>
</template>
`,
})

const nuxt = execa(resolver.resolve('./cli.js'), ['dev'])
try {
await nuxtDevReady(4000)
await this.page.goto('http://localhost:4000')
expect(await this.page.$eval('.foo', div => div.textContent)).toEqual(
'Hello world',
)
} finally {
await kill(nuxt.pid)
}
},
'do not transpile vue in node_modules': async () => {
await outputFiles({
'node_modules/foo': {
Expand Down
16 changes: 14 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { transform } from '@babel/core'
import { loadNuxtConfig } from '@nuxt/kit'
import { babel as rollupPluginBabel } from '@rollup/plugin-babel'
import { parseVueRequest } from '@vitejs/plugin-vue'
import { parse } from '@vue/compiler-sfc'
import { runCommand } from 'nuxi'
import vitePluginBabel from 'vite-plugin-babel'
import vueSfcDescriptorToString from 'vue-sfc-descriptor-to-string'

export default (command, args) =>
runCommand(command, args, {
export default async (command, args) => {
command = command === 'dev' ? '_dev' : command
if (command === '_dev') {
const nuxtConfig = await loadNuxtConfig()
process.env._PORT =
process.env.NUXT_PORT ||
process.env.NITRO_PORT ||
process.env.PORT ||
nuxtConfig.devServer.port.toString()
}

return runCommand(command, args, {
overrides: {
nitro: {
rollupConfig: {
Expand Down Expand Up @@ -51,3 +62,4 @@ export default (command, args) =>
},
},
})
}
33 changes: 16 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@
resolved "https://registry.yarnpkg.com/@nuxt/devalue/-/devalue-2.0.2.tgz#5749f04df13bda4c863338d8dabaf370f45ef7c7"
integrity sha512-GBzP8zOc7CGWyFQS6dv1lQz8VVpz5C2yRszbXufwG/9zhStTIH50EtD87NmWbTMwXDvZLNg8GIpb1UFdH93JCA==

"@nuxt/kit@3.7.0", "@nuxt/kit@^3.6.5":
"@nuxt/kit@3.7.0", "@nuxt/kit@^3.6.5", "@nuxt/kit@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@nuxt/kit/-/kit-3.7.0.tgz#14046349a7b12412e84782525ef802b65624268f"
integrity sha512-bsPRb2NTLHRacjyybhhA3pZFIqo2pxB6bcP4FQDuzlGzVTI5PtJzbfNpkmQC7q+LZt8K0pNlxKVGisDvZctk6w==
Expand Down Expand Up @@ -3151,7 +3151,7 @@
lodash.kebabcase "^4.1.1"
svg-tags "^1.0.0"

"@vue/babel-preset-jsx@dword-design/jsx#fork-babel-preset-jsx":
"@vue/babel-preset-jsx@github:dword-design/jsx#fork-babel-preset-jsx":
version "1.1.2"
resolved "https://codeload.github.com/dword-design/jsx/tar.gz/a73cb9961541a60a66b1b99a69a32e00bc66d336"
dependencies:
Expand Down Expand Up @@ -6801,9 +6801,9 @@ formdata-polyfill@^4.0.10:
fetch-blob "^3.1.2"

fraction.js@^4.2.0:
version "4.3.1"
resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.1.tgz#828c46dce1c8ad270e1c4170b3d06a2761e997d3"
integrity sha512-nx0cki48JBA6ThPeUpeKCNpdhEl/9bRS+dAEYnRUod+Z1jhFfC3K/mBLorZZntqHM+GTH3/dkkpfoT3QITYe7g==
version "4.3.2"
resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.2.tgz#ea144a08ed23a284bf9067153075f212771a92d9"
integrity sha512-9VLF466MqX1OUP7/d9r7/Vsvu6Hpp+taXBLmiR5x6mEYfT0BDkGVBt5TyA1aDu1WzIE1sF8F66evOFaz7iAEGQ==

fragment-cache@^0.2.1:
version "0.2.1"
Expand Down Expand Up @@ -6892,7 +6892,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2:
fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
Expand Down Expand Up @@ -8433,14 +8433,13 @@ istanbul-reports@^3.0.2, istanbul-reports@^3.1.6:
istanbul-lib-report "^3.0.0"

iterator.prototype@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/iterator.prototype/-/iterator.prototype-1.1.0.tgz#690c88b043d821f783843aaf725d7ac3b62e3b46"
integrity sha512-rjuhAk1AJ1fssphHD0IFV6TWL40CwRZ53FrztKx43yk2v6rguBYsY4Bj1VU4HmoMmKwZUlx7mfnhDf9cOp4YTw==
version "1.1.1"
resolved "https://registry.yarnpkg.com/iterator.prototype/-/iterator.prototype-1.1.1.tgz#ab5b790e23ec00658f5974e032a2b05188bd3a5c"
integrity sha512-9E+nePc8C9cnQldmNl6bgpTY6zI4OPRZd97fhJ/iVZ1GifIUDVV5F6x1nEDqpe8KaMEZGT4xgrwKQDxXnjOIZQ==
dependencies:
define-properties "^1.1.4"
get-intrinsic "^1.1.3"
define-properties "^1.2.0"
get-intrinsic "^1.2.1"
has-symbols "^1.0.3"
has-tostringtag "^1.0.0"
reflect.getprototypeof "^1.0.3"

jackspeak@^2.0.3:
Expand Down Expand Up @@ -10480,12 +10479,12 @@ nth-check@^2.0.1, nth-check@^2.1.1:
dependencies:
boolbase "^1.0.0"

nuxi@3.6.5, nuxi@^3.7.0:
version "3.6.5"
resolved "https://registry.yarnpkg.com/nuxi/-/nuxi-3.6.5.tgz#eceb93e6ad957138776fd544a961b2c05615ccca"
integrity sha512-4XEXYz71UiWWiKC1/cJCzqRSUEImYRmjcvKpSsBKMU58ALYVSx5KIoas5SwLO8tEKO5BS4DAe4u7MYix7hfuHQ==
nuxi@^3.7.0:
version "3.7.3"
resolved "https://registry.yarnpkg.com/nuxi/-/nuxi-3.7.3.tgz#e979601b763cd9c57bec400c265e3879ac907aa4"
integrity sha512-Cg+ygRmhonE6PwAtDeKvKU/0VRqEyzmSSoJYfr0MzwIxQYrBSnLvw0z3UgJl/8MgFKjiZ5Y4wBUEiRsUw8O6uw==
optionalDependencies:
fsevents "~2.3.2"
fsevents "~2.3.3"

nuxt-dev-ready@^2.0.1:
version "2.0.1"
Expand Down

0 comments on commit 52abdea

Please sign in to comment.