Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rspack_plugin_esm_library/src/chunk_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ pub struct ChunkLinkContext {
pub raw_import_stmts: FxIndexMap<(String, Option<String>), ImportSpec>,

/**
const symbol = __webpack_require__(module_id)
`const symbol = __webpack_require__(module_id)`
*/
pub required: IdentifierIndexMap<ExternalInterop>,

Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_plugin_esm_library/src/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ var {} = {{}};
info.module,
Self::add_require(
*info_id,
None,
from,
Some(info.name.clone().expect("should have symbol")),
all_used_names,
required,
Expand Down Expand Up @@ -2062,7 +2062,7 @@ var {} = {{}};
info.module,
Self::add_require(
*info_id,
None,
from,
Some(info.name.clone().expect("should have symbol")),
all_used_names,
required,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exports["default"] = 'esm'

},
});
// ./index.js
// ./lib.js
const foo = __webpack_require__("./foo.cjs");
const from_esm = __webpack_require__("./from-esm.cjs");

Expand All @@ -40,6 +40,8 @@ it('should have correct import', () => {
expect(/* inlined export .value */("value")).toBe('value')
})

// ./index.js


```

Expand Down
15 changes: 1 addition & 14 deletions tests/rspack-test/esmOutputCases/interop/contains-cjs/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
import { foo } from './foo.cjs'
import v1 from './foo.cjs'
import v2 from './from-esm.cjs'
import { value } from './foo.js'

it('should have correct import', () => {
expect(v1).toHaveProperty('foo')
expect(v1.foo).toBe(42)

expect(v2).toBe('esm')

expect(foo).toBe(42)
expect(value).toBe('value')
})
import './lib'
14 changes: 14 additions & 0 deletions tests/rspack-test/esmOutputCases/interop/contains-cjs/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { foo } from './foo.cjs'
import v1 from './foo.cjs'
import v2 from './from-esm.cjs'
import { value } from './foo.js'

it('should have correct import', () => {
expect(v1).toHaveProperty('foo')
expect(v1.foo).toBe(42)

expect(v2).toBe('esm')

expect(foo).toBe(42)
expect(value).toBe('value')
})
Loading