-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deconflict export named declartion (#386)
- Loading branch information
Showing
6 changed files
with
89 additions
and
0 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
63 changes: 63 additions & 0 deletions
63
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_export_named_function/artifacts.snap
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,63 @@ | ||
--- | ||
source: crates/rolldown/tests/common/case.rs | ||
expression: content | ||
input_file: crates/rolldown/tests/fixtures/deconflict/wrapped_esm_export_named_function | ||
--- | ||
# Assets | ||
|
||
## main.mjs | ||
|
||
```js | ||
import { default as assert } from "assert"; | ||
// <runtime> | ||
var __defProp = Object.defineProperty | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor | ||
var __getOwnPropNames = Object.getOwnPropertyNames | ||
var __hasOwnProp = Object.prototype.hasOwnProperty | ||
var __esm = (fn, res) => function () { | ||
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res | ||
} | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === 'object' || typeof from === 'function') | ||
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
key = keys[i] | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: (k => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }) | ||
} | ||
return to | ||
} | ||
var __toCommonJS = mod => __copyProps(__defProp({}, '__esModule', { value: true }), mod) | ||
// foo.js | ||
function foo$1(a$1$1) { | ||
console.log(a$1$1, a$1) | ||
} | ||
var foo_ns = { | ||
get foo() { return foo$1 } | ||
}; | ||
var init_foo = __esm({ | ||
'foo.js'() { | ||
const a$1 = 1; | ||
} | ||
}); | ||
// bar.js | ||
init_foo(); | ||
var bar_default = { foo: foo$1 } | ||
// main.js | ||
// make foo `a` conflict | ||
const { foo } = bar_default | ||
assert.strictEqual(typeof foo, 'function') | ||
init_foo() | ||
``` |
3 changes: 3 additions & 0 deletions
3
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_export_named_function/bar.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,3 @@ | ||
import { foo } from './foo' | ||
|
||
export default { foo } |
5 changes: 5 additions & 0 deletions
5
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_export_named_function/foo.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,5 @@ | ||
const a = 1; | ||
|
||
export function foo(a$1) { | ||
console.log(a$1, a) | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_export_named_function/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 @@ | ||
import assert from 'assert' | ||
import bar from './bar' | ||
|
||
const a = 2; // make foo `a` conflict | ||
|
||
const { foo } = bar | ||
|
||
assert.strictEqual(typeof foo, 'function') | ||
|
||
require('./foo') |
7 changes: 7 additions & 0 deletions
7
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_export_named_function/test.config.json
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,7 @@ | ||
{ | ||
"input": { | ||
"external": [ | ||
"assert" | ||
] | ||
} | ||
} |