Skip to content

Commit

Permalink
wip: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 9, 2024
1 parent 40314fc commit 8bad3d2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/misc/rolldown-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ self.__rolldown_runtime = {
})
this.executeModuleStack.push(id)
factory({
require: this.require.bind(this),
module,
exports: module.exports,
require: this.require.bind(this),
ensureChunk: this.ensureChunk.bind(this),
__toCommonJS,
__toESM,
__export,
Expand Down
2 changes: 2 additions & 0 deletions playground/rolldown-dev-react/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { throwError } from './error'
import './test-style.css'
import testStyleInline from './test-style-inline.css?inline'
import testStyleUrl from './test-style-url.css?url'
import { DynamicImport } from './dynamic-import'

// TODO: isolating finalizer doesn't rewrite yet
// const testAssetTxt = new URL('./test-asset.txt', import.meta.url).href;
Expand Down Expand Up @@ -36,6 +37,7 @@ export function App() {
<pre>
[css?inline] <span className="test-style-inline">orange</span>
</pre>
<DynamicImport />
</div>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions playground/rolldown-dev-react/src/dynamic-import-dep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default '[ok]'
19 changes: 19 additions & 0 deletions playground/rolldown-dev-react/src/dynamic-import.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'

export function DynamicImport() {
const [value, setValue] = React.useState('???')

return (
<div className="test-dynamic-import">
<button
onClick={async () => {
const dep = await import('./dynamic-import-dep')
setValue(dep.default)
}}
>
dynamic-import
</button>{' '}
<span>{value}</span>
</div>
)
}

0 comments on commit 8bad3d2

Please sign in to comment.