From 8bad3d23bba77138c66655f39052e0d3f8f3f8f1 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Mon, 9 Dec 2024 12:06:00 +0900 Subject: [PATCH] wip: add example --- packages/vite/misc/rolldown-runtime.js | 3 ++- playground/rolldown-dev-react/src/app.tsx | 2 ++ .../src/dynamic-import-dep.ts | 1 + .../rolldown-dev-react/src/dynamic-import.tsx | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 playground/rolldown-dev-react/src/dynamic-import-dep.ts create mode 100644 playground/rolldown-dev-react/src/dynamic-import.tsx diff --git a/packages/vite/misc/rolldown-runtime.js b/packages/vite/misc/rolldown-runtime.js index f1514c9cffbe1a..519c153a66200d 100644 --- a/packages/vite/misc/rolldown-runtime.js +++ b/packages/vite/misc/rolldown-runtime.js @@ -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, diff --git a/playground/rolldown-dev-react/src/app.tsx b/playground/rolldown-dev-react/src/app.tsx index 4138c54e249a0f..4ef63cbcc10ff9 100644 --- a/playground/rolldown-dev-react/src/app.tsx +++ b/playground/rolldown-dev-react/src/app.tsx @@ -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; @@ -36,6 +37,7 @@ export function App() {
           [css?inline] orange
         
+ ) diff --git a/playground/rolldown-dev-react/src/dynamic-import-dep.ts b/playground/rolldown-dev-react/src/dynamic-import-dep.ts new file mode 100644 index 00000000000000..ca3fb00232166e --- /dev/null +++ b/playground/rolldown-dev-react/src/dynamic-import-dep.ts @@ -0,0 +1 @@ +export default '[ok]' diff --git a/playground/rolldown-dev-react/src/dynamic-import.tsx b/playground/rolldown-dev-react/src/dynamic-import.tsx new file mode 100644 index 00000000000000..ac046da3dd4321 --- /dev/null +++ b/playground/rolldown-dev-react/src/dynamic-import.tsx @@ -0,0 +1,19 @@ +import React from 'react' + +export function DynamicImport() { + const [value, setValue] = React.useState('???') + + return ( +
+ {' '} + {value} +
+ ) +}