-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow cjs to be both entry and dependency (#336)
<!-- Thank you for contributing! --> ### Description <!-- Please insert your description here and provide especially info about the "what" this PR is solving --> ### Test Plan <!-- e.g. is there anything you'd like reviewers to focus on? --> ---
- Loading branch information
Showing
6 changed files
with
81 additions
and
4 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
4 changes: 4 additions & 0 deletions
4
crates/rolldown/tests/fixtures/misc/cjs_entry_as_dependency/_test.mjs
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,4 @@ | ||
import assert from 'assert' | ||
import main from './dist/main.mjs' | ||
import main2 from './dist/main2.mjs' | ||
assert(main === main2) |
46 changes: 46 additions & 0 deletions
46
crates/rolldown/tests/fixtures/misc/cjs_entry_as_dependency/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,46 @@ | ||
--- | ||
source: crates/rolldown/tests/common/case.rs | ||
expression: content | ||
input_file: crates/rolldown/tests/fixtures/misc/cjs_entry_as_dependency | ||
--- | ||
# Assets | ||
|
||
## 2.mjs | ||
|
||
```js | ||
import { __commonJS } from "./_rolldown_runtime.mjs"; | ||
// main2.js | ||
var require_main2 = __commonJS({ | ||
'main2.js'(exports, module) { | ||
module.exports = {} | ||
} | ||
}); | ||
export { require_main2 }; | ||
``` | ||
## main.mjs | ||
|
||
```js | ||
import { __commonJS, __toESM } from "./_rolldown_runtime.mjs"; | ||
import { require_main2 } from "./2.mjs"; | ||
// main.js | ||
var require_main = __commonJS({ | ||
'main.js'(exports, module) { | ||
var import_main2 = __toESM(require_main2()); | ||
module.exports = import_main2.default | ||
} | ||
}); | ||
export default require_main(); | ||
``` | ||
## main2.mjs | ||
|
||
```js | ||
import { require_main2 } from "./2.mjs"; | ||
export default require_main2(); | ||
``` |
3 changes: 3 additions & 0 deletions
3
crates/rolldown/tests/fixtures/misc/cjs_entry_as_dependency/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,3 @@ | ||
import main2 from './main2.js' | ||
module.exports = main2 | ||
|
1 change: 1 addition & 0 deletions
1
crates/rolldown/tests/fixtures/misc/cjs_entry_as_dependency/main2.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 @@ | ||
module.exports = {} |
14 changes: 14 additions & 0 deletions
14
crates/rolldown/tests/fixtures/misc/cjs_entry_as_dependency/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,14 @@ | ||
{ | ||
"input": { | ||
"input": [ | ||
{ | ||
"name": "main", | ||
"import": "./main.js" | ||
}, | ||
{ | ||
"name": "main2", | ||
"import": "./main2.js" | ||
} | ||
] | ||
} | ||
} |