Skip to content

Commit 7dc7588

Browse files
committed
fix(player): cdn breaking due to node modules mangling
1 parent 6a46433 commit 7dc7588

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

packages/vidstack/rollup.config.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
55
import { nodeResolve } from '@rollup/plugin-node-resolve';
66
import chokidar from 'chokidar';
77
import * as eslexer from 'es-module-lexer';
8-
import { build } from 'esbuild';
8+
import { build, transform as esbuildTransform } from 'esbuild';
99
import fsExtra from 'fs-extra';
1010
import { globbySync } from 'globby';
1111
import { defineConfig } from 'rollup';
@@ -231,16 +231,28 @@ function defineNPMBundle({ target, type, minify }) {
231231
platform: isServer ? 'node' : 'browser',
232232
minify: minify,
233233
legalComments: 'none',
234-
mangleProps: shouldMangle ? /^_/ : undefined,
235-
mangleCache: shouldMangle ? MANGLE_CACHE : undefined,
236-
reserveProps: shouldMangle ? /^__/ : undefined,
237234
define: {
238235
__DEV__: !isProd && !isServer ? 'true' : 'false',
239236
__SERVER__: isServer ? 'true' : 'false',
240237
__CDN__: MODE_CDN ? 'true' : 'false',
241238
__TEST__: 'false',
242239
},
243240
}),
241+
shouldMangle && {
242+
name: 'mangle',
243+
async transform(code, id) {
244+
if (id.includes('node_modules')) return null;
245+
return (
246+
await esbuildTransform(code, {
247+
target: 'esnext',
248+
platform: 'neutral',
249+
mangleProps: /^_/,
250+
mangleCache: MANGLE_CACHE,
251+
reserveProps: /^__/,
252+
})
253+
).code;
254+
},
255+
},
244256
],
245257
};
246258
}

0 commit comments

Comments
 (0)