Skip to content

feat: add module_preload_polyfill plugin#1840

Merged
underfin merged 3 commits intorolldown:mainfrom
shulaoda:feat/module-preload-polyfill-plugin
Aug 2, 2024
Merged

feat: add module_preload_polyfill plugin#1840
underfin merged 3 commits intorolldown:mainfrom
shulaoda:feat/module-preload-polyfill-plugin

Conversation

@shulaoda
Copy link
Copy Markdown
Member

@shulaoda shulaoda commented Aug 2, 2024

Description

closed #1827

This PR implements Vite's module-preload-polyfill plugin as a built-in Rolldown plugin.

Notes

I don't know how to implement the following content skip & isModernFlag and whether it is necessary.

// `isModernFlag` is only available during build since it is resolved by `vite:build-import-analysis`
const skip = config.command !== 'build' || config.build.ssr

...

    load(id) {
      if (id === resolvedModulePreloadPolyfillId) {
        if (skip) {
          return ''
        }
        if (!polyfillString) {
          polyfillString = `${isModernFlag}&&(${polyfill.toString()}());`
        }
        return { code: polyfillString, moduleSideEffects: true }
      }
    },

@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 2, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 0f058c0
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66ac8a41821c950008e69872

@hyf0
Copy link
Copy Markdown
Member

hyf0 commented Aug 2, 2024

LGTM. Could you fix the CI / Repo Validation.

@underfin
Copy link
Copy Markdown
Contributor

underfin commented Aug 2, 2024

skip & isModernFlag

Look like the skip is unnecessary at here, we could avoid injecting the import at BuildHtmlPlugin,
The isModernFlag is enable at format is es, it also could avoid injecting.

@underfin
Copy link
Copy Markdown
Contributor

underfin commented Aug 2, 2024

Thank you.

@underfin underfin enabled auto-merge August 2, 2024 07:36
@underfin underfin added this pull request to the merge queue Aug 2, 2024
Merged via the queue into rolldown:main with commit 0651db0 Aug 2, 2024
@shulaoda shulaoda deleted the feat/module-preload-polyfill-plugin branch August 2, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modulePreloadPolyfillPlugin

4 participants