Skip to content

Commit

Permalink
fix: foo
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design committed Feb 13, 2024
1 parent b6a5107 commit bbf566b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
},
"dependencies": {
"@babel/core": "^7.10.2",
"@dword-design/suppress-babel-register-esm-warning": "^1.1.10",
"@rollup/plugin-babel": "^6.0.3",
"@vitejs/plugin-vue": "^5.0.3",
"@vue/compiler-sfc": "^3.3.4",
"depcheck-package-name": "^3.0.1",
"execa": "^8.0.1",
"suppress-experimental-warnings": "^1.1.17",
"vite-plugin-babel": "^1.1.3",
"vue-sfc-descriptor-to-string": "^2.0.0"
},
Expand All @@ -43,7 +46,6 @@
"@dword-design/tester-plugin-puppeteer": "^3.0.0",
"@dword-design/tester-plugin-tmp-dir": "^2.1.26",
"axios": "^1.4.0",
"depcheck-package-name": "^3.0.1",
"fs-extra": "^11.1.1",
"nuxt": "^3.7.0",
"nuxt-dev-ready": "^3.0.0",
Expand Down
9 changes: 8 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#!/usr/bin/env node

import packageName from 'depcheck-package-name'
import { execa } from 'execa'
import { createRequire } from 'module'

const resolver = createRequire(import.meta.url)
try {
await execa(
'node',
[resolver.resolve('./inner-cli.js'), ...process.argv.slice(2)],
[
'--experimental-loader=babel-register-esm',
`--require=${packageName`suppress-experimental-warnings`}`,
`--require=${packageName`@dword-design/suppress-babel-register-esm-warning`}`,
resolver.resolve('./inner-cli.js'),
...process.argv.slice(2),
],
{ stdio: 'inherit' },
)
} catch (error) {
Expand Down
30 changes: 29 additions & 1 deletion src/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,35 @@ export default tester(
'This experimental syntax requires enabling the parser plugin: "pipelineOperator".',
)
},
async 'file imported from api'() {
async 'file imported from api dev'() {
await outputFiles({
'model/foo.js': 'export default 1 |> x => x * 2',
'pages/index.vue': endent`
<template>
<div class="foo" />
</template>
`,
'server/api/foo.get.js': endent`
import { defineEventHandler } from '#imports'
import foo from '@/model/foo.js'
export default defineEventHandler(() => foo)
`,
})

const nuxt = execa(resolver.resolve('./cli.js'), ['dev'], {
env: { NODE_OPTIONS: '' },
})
try {
await nuxtDevReady()
await this.page.goto('http://localhost:3000')
await this.page.waitForSelector('.foo')
} finally {
await kill(nuxt.pid)
}
},
async 'file imported from api no console warnings'() {
await outputFiles({
'model/foo.js': 'export default 1 |> x => x * 2',
'pages/index.vue': endent`
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@
resolved "https://registry.yarnpkg.com/@dword-design/setup-test/-/setup-test-1.0.2.tgz#0bea8800f2349de41a9f42986d09bf89ff69fd1c"
integrity sha512-W861E4cbZmUaYri3mhZNfpo2Yxc1hHPP0v5iDZGE+h9EHplY+8tzWaTNHIF67DmrcDLP79zxd/lkJX0xZs0l8Q==

"@dword-design/suppress-babel-register-esm-warning@^1.1.0":
"@dword-design/suppress-babel-register-esm-warning@^1.1.0", "@dword-design/suppress-babel-register-esm-warning@^1.1.10":
version "1.1.10"
resolved "https://registry.yarnpkg.com/@dword-design/suppress-babel-register-esm-warning/-/suppress-babel-register-esm-warning-1.1.10.tgz#1fc68ca173a513a9f46642740e47cc3847cf391f"
integrity sha512-VkXvIeTTutLLGr05RQEcuAs+ePlJa3yN2xuUuA3OtfXywdKlxA9r5xMFzGnHVc/y8T/95Z2eOEBpCn2QkChokg==
Expand Down Expand Up @@ -13195,7 +13195,7 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

suppress-experimental-warnings@^1.1.0:
suppress-experimental-warnings@^1.1.0, suppress-experimental-warnings@^1.1.17:
version "1.1.17"
resolved "https://registry.yarnpkg.com/suppress-experimental-warnings/-/suppress-experimental-warnings-1.1.17.tgz#5408a8511dcb088c2d28133ce873fef3b3f1d46d"
integrity sha512-n1huqqtVdNSTV04x0lC9gfBsCl6X+RRA10B6VTw8kQjrNbkwkU6DJB/qTbQFjO+ItYT9VbGe3NvuS4XWq5vUEQ==
Expand Down

0 comments on commit bbf566b

Please sign in to comment.