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: Use correct format when resolving exports from sub-modules #140

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,19 @@ async function processModule ({ srcUrl, context, parentGetSource, parentResolve,
if (isStarExportLine(n) === true) {
const [, modFile] = n.split('* from ')

let modUrl
async function processSubModule (url, ctx) {
const setters = await processModule({ srcUrl: url, context: ctx, parentGetSource, parentResolve, excludeDefault: true })
for (const [name, setter] of setters.entries()) {
addSetter(name, setter, true)
}
}

if (isBareSpecifier(modFile)) {
// Bare specifiers need to be resolved relative to the parent module.
const result = await parentResolve(modFile, { parentURL: srcUrl })
modUrl = result.url
await processSubModule(result.url, { ...context, format: result.format })
} else {
modUrl = new URL(modFile, srcUrl).href
}

const setters = await processModule({
srcUrl: modUrl,
context,
parentGetSource,
parentResolve,
excludeDefault: true
})
for (const [name, setter] of setters.entries()) {
addSetter(name, setter, true)
await processSubModule(new URL(modFile, srcUrl).href, context)
}
} else {
addSetter(n, `
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"imhotap": "^2.1.0",
"openai": "^4.47.2",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
"typescript": "^4.7.4",
"vue": "^3.4.31"
},
"dependencies": {
"acorn": "^8.8.2",
Expand Down
5 changes: 5 additions & 0 deletions test/hook/vue-server-renderer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// https://github.com/nodejs/import-in-the-middle/issues/139
import { strictEqual } from 'assert'
jsumners-nr marked this conversation as resolved.
Show resolved Hide resolved
import * as lib from 'vue/server-renderer'

strictEqual(typeof lib.renderToString, 'function')
Loading