Я загружаю скрипт примерно так (условно) - но он заканчивается в комплекте:
function loadScript(src) {
if (isNode) return
const xhrObj = new window.XMLHttpRequest()
xhrObj.open('GET', src, false)
xhrObj.send('')
const se = window.document.createElement('script')
se.type = 'text/javascript'
se.text = xhrObj.responseText
window.document.head.appendChild(se)
}
export default function () {
// uses feature detection from polyfilll in quesiton
if (globalSpace.Intl && globalSpace.Intl.DateTimeFormat
&& !globalSpace.Intl._DateTimeFormatTimeZone) { // eslint-disable-line no-underscore-dangle
loadScript('https://unpkg.com/date-time-format-timezone@latest/build/browserified/date-time-format-timezone-complete-min.js')
}
}
Я изменил конфигурацию, указав на абсолютный URL, так как в соответствии с документами, которые должны пройти, -https://rollupjs.org/guide/en#big-list-of-options.
module.exports = (config) => {
const { input, fileName, name } = config
return {
input: {
input,
external: [
'dayjs',
'https://unpkg.com/date-time-format-timezone@latest/build/browserified/date-time-format-timezone-complete-min.js'
],
plugins: [
babel({
exclude: 'node_modules/**'
}),
uglify()
]
},
output: {
file: fileName,
format: 'umd',
name: name || 'dayjs',
globals: {
dayjs: 'dayjs'
}
}
}
}