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

parseResource marks all script chunks as modules #44

Open
IlyaSemenov opened this issue Nov 14, 2022 · 1 comment
Open

parseResource marks all script chunks as modules #44

IlyaSemenov opened this issue Nov 14, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@IlyaSemenov
Copy link

parseResource always marks all scripts as modules:

export const parseResource = (path: string) => {
const chunk: Omit<ResourceMeta, 'file'> = {}
const extension = path.replace(/\?.*/, '').split('.').pop() || ''
const asType = getAsType(extension)
if (asType) {
chunk.resourceType = asType
if (asType === 'script') {
chunk.module = true
}

This in turn affects normalizeViteManifest which emits all script chunks as having module: true:

export function normalizeViteManifest (manifest: ViteManifest | Manifest): Manifest {
const _manifest: Manifest = {}
for (const file in manifest) {
const chunk = manifest[file]
_manifest[file] = { ...parseResource(chunk.file || file), ...chunk }

Then, renderScripts always emits <script type="module"> preventing legacy browsers from even loading the code:

export function renderScripts (ssrContext: SSRContext, rendererContext: RendererContext): string {
const { scripts } = getRequestDependencies(ssrContext, rendererContext)
return Object.values(scripts).map(resource => renderScriptToString({
type: resource.module ? 'module' : null,

See nuxt/bridge#621 for the actual user-facing issue.

@danielroe danielroe added the bug Something isn't working label Nov 14, 2022 — with Volta.net
@danielroe
Copy link
Member

I think this is just meant to be the default. What we need to do in Nuxt Bridge is explicitly modify the manifest to mark module: false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants