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 634a34b
Showing
14 changed files
with
213 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,42 @@ | ||
import Module, { AstContext } from '../../Module'; | ||
import { RenderOptions } from '../../utils/renderHelpers'; | ||
import { InclusionContext } from '../ExecutionContext'; | ||
// 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; | ||
} | ||
|
||
renderFirst() { | ||
return true; | ||
} | ||
|
||
static get isNamespace() { | ||
return true; | ||
} | ||
} |
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); |
Oops, something went wrong.