/
githubmirror
/
taro
Обзор
Документация
Войти
/
githubmirror
/
taro
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/taro-loader/src/component.ts
35 строк
1 KB
Angus Chan
fix(loader): 缓存Page 和 App 源码的同时也对 sourcemap 进行缓存,并将其传递下去,避免 sourcemap 链断裂 (#18506)
31 окт 2025, 05:04
Не верифицирован
31 окт 2025, 05:04
9523842
Код
Авторство
О чём код?
import * as path from 'node:path' import { entryCache } from './entry-cache' import { stringifyRequest } from './util' import type * as webpack from 'webpack' export default function (this: webpack.LoaderContext<any>, source: string, map?: any) { const options = this.getOptions() const stringify = (s: string): string => stringifyRequest(this, s) const pageName = options.name const { isNeedRawLoader } = options.loaderMeta // raw is a placeholder loader to locate changed .vue resource const raw = path.join(__dirname, 'raw.js') const entryCacheLoader = path.join(__dirname, 'entry-cache.js') + `?name=${pageName}` entryCache.set(pageName, { source, map }) const componentPath = isNeedRawLoader ? ['!', raw, entryCacheLoader, this.resourcePath].join('!') : ['!', entryCacheLoader, this.resourcePath].join('!') const { globalObject } = this._compilation?.outputOptions || { globalObject: 'wx' } const prerender = ` if (typeof PRERENDER !== 'undefined') { ${globalObject}._prerender = inst }` return `import { createComponentConfig } from '@tarojs/runtime' import component from ${stringify(componentPath)} var inst = Component(createComponentConfig(component, '${pageName}')) ${options.prerender ? prerender : ''} export default component ` }