Unverified Commit 54b10da4 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Handle shorthand properties in constant codegen

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 2957868a
...@@ -54,6 +54,10 @@ function readShortDefault() { ...@@ -54,6 +54,10 @@ function readShortDefault() {
return shortDefault return shortDefault
} }
function readShorthandProperties() {
return { shortString, smallNumber }
}
it('inlines short primitive exports during code generation', () => { it('inlines short primitive exports during code generation', () => {
expect(readShortValues()).toEqual([ expect(readShortValues()).toEqual([
'dev', 'dev',
...@@ -68,6 +72,10 @@ it('inlines short primitive exports during code generation', () => { ...@@ -68,6 +72,10 @@ it('inlines short primitive exports during code generation', () => {
expect(readMode()).toBe('dev') expect(readMode()).toBe('dev')
expect(readStaticNamespace()).toBe('ns') expect(readStaticNamespace()).toBe('ns')
expect(readShortDefault()).toBe('def') expect(readShortDefault()).toBe('def')
expect(readShorthandProperties()).toEqual({
shortString: 'dev',
smallNumber: 1,
})
const source = readShortValues.toString() const source = readShortValues.toString()
expect(source).toContain('"dev"') expect(source).toContain('"dev"')
...@@ -81,6 +89,11 @@ it('inlines short primitive exports during code generation', () => { ...@@ -81,6 +89,11 @@ it('inlines short primitive exports during code generation', () => {
expect(readStaticNamespace.toString()).not.toContain('staticNamespace') expect(readStaticNamespace.toString()).not.toContain('staticNamespace')
expect(readShortDefault.toString()).toContain('"def"') expect(readShortDefault.toString()).toContain('"def"')
expect(readShortDefault.toString()).not.toContain('shortDefault') expect(readShortDefault.toString()).not.toContain('shortDefault')
expect(readShorthandProperties.toString()).toContain('shortString:')
expect(readShorthandProperties.toString()).toContain('smallNumber:')
expect(readShorthandProperties.toString()).toContain(
'TURBOPACK compile-time value'
)
}) })
it('omits inlined export modules without using values for analysis', () => { it('omits inlined export modules without using values for analysis', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment