-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: defonflict export default function (#385)
- Loading branch information
Showing
12 changed files
with
148 additions
and
3 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
32 changes: 32 additions & 0 deletions
32
crates/rolldown/tests/fixtures/deconflict/default_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,32 @@ | ||
--- | ||
source: crates/rolldown/tests/common/case.rs | ||
expression: content | ||
input_file: crates/rolldown/tests/fixtures/deconflict/default_function | ||
--- | ||
# Assets | ||
|
||
## main.mjs | ||
|
||
```js | ||
import { default as assert } from "assert"; | ||
// foo.js | ||
const a$1 = 1; | ||
function foo$1(a$1$1) { | ||
console.log(a$1$1, a$1) | ||
} | ||
// bar.js | ||
var bar_default = { foo: foo$1 } | ||
// main.js | ||
const a = 2; // make foo `a` conflict | ||
const { foo } = bar_default | ||
assert.strictEqual(typeof foo, 'function') | ||
``` |
3 changes: 3 additions & 0 deletions
3
crates/rolldown/tests/fixtures/deconflict/default_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/default_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 default function foo(a$1) { | ||
console.log(a$1, a) | ||
} |
8 changes: 8 additions & 0 deletions
8
crates/rolldown/tests/fixtures/deconflict/default_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,8 @@ | ||
import assert from 'assert' | ||
import bar from './bar' | ||
|
||
const a = 2; // make foo `a` conflict | ||
|
||
const { foo } = bar | ||
|
||
assert.strictEqual(typeof foo, 'function') |
8 changes: 8 additions & 0 deletions
8
crates/rolldown/tests/fixtures/deconflict/default_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,8 @@ | ||
{ | ||
"input": { | ||
"external": [ | ||
"assert" | ||
], | ||
"treeshake": false | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_default_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_default_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 default() { 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 | ||
const a = 2; // 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_default_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_default_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 default function foo(a$1) { | ||
console.log(a$1, a) | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_default_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') |
8 changes: 8 additions & 0 deletions
8
crates/rolldown/tests/fixtures/deconflict/wrapped_esm_default_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,8 @@ | ||
{ | ||
"input": { | ||
"external": [ | ||
"assert" | ||
], | ||
"treeshake": false | ||
} | ||
} |