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

demo ssrTransform without getter #18725

Closed
Closed
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
11 changes: 6 additions & 5 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ async function ssrTransformScript(
s.appendLeft(
position,
`\nObject.defineProperty(${ssrModuleExportsKey}, ${JSON.stringify(name)}, ` +
`{ enumerable: true, configurable: true, get(){ return ${local} }});`,
`{ enumerable: true, configurable: true, value: ${local} });`,
// `{ enumerable: true, configurable: true, get(){ return ${local} }});`,
)
}

Expand Down Expand Up @@ -331,7 +332,7 @@ async function ssrTransformScript(
}
}

let injectIdentityFunction = false
const injectIdentityFunction = false
// 3. convert references to import bindings & import.meta references
walk(ast, {
onIdentifier(id, parent, parentStack) {
Expand Down Expand Up @@ -365,9 +366,9 @@ async function ssrTransformScript(
s.update(id.start, id.end, binding)
// wrap with identity function to avoid method binding `this`
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#method_binding
s.prependRight(id.start, `${ssrIdentityFunction}(`)
s.appendLeft(id.end, `)`)
injectIdentityFunction = true
// s.prependRight(id.start, `${ssrIdentityFunction}(`)
// s.appendLeft(id.end, `)`)
// injectIdentityFunction = true
} else if (
// don't transform class name identifier
!(parent.type === 'ClassExpression' && id === parent.id)
Expand Down
Loading