Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: load client build as esm #10

Open
wants to merge 2 commits into
base: fix-require-external
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions packages/vite/misc/rolldown-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ var __toBinary = /* @__PURE__ */ (() => {
}
})()

// TODO: for now need to expose these utilities used by IsolatingModuleFinalizermodule
self.__toCommonJS = __toCommonJS
self.__toESM = __toESM
self.__export = __export
self.__reExport = __reExport

var rolldown_runtime = (self.rolldown_runtime = {
patching: false,
patchedModuleFactoryMap: {},
Expand Down
8 changes: 1 addition & 7 deletions packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,13 +775,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): RolldownPlugin {
tag: 'script',
attrs: {
...(isAsync ? { async: true } : {}),
...(config.experimental.rolldownDev
? {
defer: true,
}
: {
type: 'module',
}),
type: 'module',
// crossorigin must be set not only for serving assets in a different origin
// but also to make it possible to preload the script using `<link rel="preload">`.
// `<script type="module">` used to fetch the script with credential mode `omit`,
Expand Down
8 changes: 2 additions & 6 deletions packages/vite/src/node/server/environments/rolldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ class RolldownModuleRunner {
}
code = `\
'use strict';(${Object.keys(context).join(',')})=>{{${code}
// TODO: need to re-expose runtime utilities for now
self.__toCommonJS = __toCommonJS;
self.__export = __export;
self.__toESM = __toESM;
}}
//# sourceURL=${sourceURL}
//# sourceMappingSource=rolldown-module-runner
Expand Down Expand Up @@ -596,12 +592,12 @@ function getReactRefreshRuntimeCode() {
(() => {
__react_refresh_runtime.injectIntoGlobalHook(self);

__react_refresh_transform_define = (file) => [
self.__react_refresh_transform_define = (file) => [
__react_refresh_runtime.createSignatureFunctionForTransform,
(type, id) => __react_refresh_runtime.register(type, file + '_' + id)
];

__react_refresh_transform_setupHot = (hot) => {
self.__react_refresh_transform_setupHot = (hot) => {
hot.accept((prev) => {
debouncedRefresh();
});
Expand Down
2 changes: 1 addition & 1 deletion playground/rolldown-dev-ssr/src/entry-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const handler: Connect.SimpleHandleFunction = (req, res) => {
</head>
<body>
<div id="root">${ssrHtml}</div>
<script src="/entry-client.js"></script>
<script type="module" src="/entry-client.js"></script>
</body>
</html>
`)
Expand Down
Loading