Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
396f238
commit 150abcf
Showing
14 changed files
with
204 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Module, { AstContext } from '../../Module'; | ||
import { RenderOptions } from '../../utils/renderHelpers'; | ||
import { InclusionContext } from '../ExecutionContext'; | ||
import ExportDefaultVariable from './ExportDefaultVariable'; | ||
import Variable from './Variable'; | ||
|
||
export default class SyntheticNamedExport extends Variable { | ||
context: AstContext; | ||
defaultVariable: ExportDefaultVariable; | ||
module: Module; | ||
|
||
constructor(context: AstContext, name: string, defaultVariable: ExportDefaultVariable) { | ||
super(name); | ||
this.context = context; | ||
this.module = context.module; | ||
this.defaultVariable = defaultVariable; | ||
} | ||
|
||
include(context: InclusionContext) { | ||
if (!this.included) { | ||
this.included = true; | ||
this.context.includeVariable(context, this.defaultVariable); | ||
} | ||
} | ||
|
||
renderBlock(options: RenderOptions) { | ||
const _ = options.compact ? '' : ' '; | ||
const name = this.getName(); | ||
const defaultVariable = this.defaultVariable.getName(); | ||
const output = `${options.varOrConst} ${name}${_}=${_}${defaultVariable}.${this.name};`; | ||
return output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
test/chunking-form/samples/synthetic-named-exports/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
description: 'simple chunking', | ||
options: { | ||
input: ['main.js'], | ||
plugins: [ | ||
{ | ||
resolveId(id) { | ||
if (id === './dep1.js') { | ||
return { | ||
id, | ||
syntheticNamedExports: true | ||
}; | ||
} | ||
return null; | ||
} | ||
} | ||
] | ||
} | ||
}; |
14 changes: 14 additions & 0 deletions
14
test/chunking-form/samples/synthetic-named-exports/_expected/amd/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
define(function () { 'use strict'; | ||
|
||
const d = { | ||
fn: 42 | ||
}; | ||
|
||
var fn = d.fn; | ||
|
||
var foo = d.foo; | ||
|
||
console.log(fn); | ||
console.log(foo); | ||
|
||
}); |
12 changes: 12 additions & 0 deletions
12
test/chunking-form/samples/synthetic-named-exports/_expected/cjs/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
const d = { | ||
fn: 42 | ||
}; | ||
|
||
var fn = d.fn; | ||
|
||
var foo = d.foo; | ||
|
||
console.log(fn); | ||
console.log(foo); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/synthetic-named-exports/_expected/es/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const d = { | ||
fn: 42 | ||
}; | ||
|
||
var fn = d.fn; | ||
|
||
var foo = d.foo; | ||
|
||
console.log(fn); | ||
console.log(foo); |
Oops, something went wrong.