Closed zhe-he closed 10 months ago
Is it possible to output two versions, one for browser and one for nodejs
source:
/** index.js */
import { test } from "./platform";
console.log(test)
/** platform-node.js */
module.exports.test = 1;
/** platform-browser.js */
export const test = 2;
/** config.js */
alias: {
platform: process.env.isNode ? './platform-node' : './platform-browser'
}
output:
index.browser.js
index.node.js
Or automatically replace node variables at the end of compilation source:
const t1 = import.meta.env.isNode;
const t2 = process.env.isNode;
const test = import.meta.env.isNode ? 'a' : 'b';
const test2 = process.env.isNode ? 'c' : 'd';
const test3 = t1 ? 'e' : 'f';
output:
/** nodejs */
const t1 = true;
const t2 = true;
const test = 'a'
const test2 = 'c'
const test3 = 'e'
/** browser */
const t1 = false;
const t2 = false;
const test = 'b'
const test2 = 'd'
const test3 = 'f'
I am also running into this issue any updates?
@DanielleConstell This project hasn't been updated for 1.5 years. Currently, my approach is to ignore this kind of error, and the detailed configuration is as follows.
rollupOptions: {
onwarn(warning, rollupWarn) {
if (warning.code == "EVAL" && warning.id?.includes("flexsearch")) return;
rollupWarn(warning);
}
}
@zhe-he Thanks, that also works 😄
Thanks for the hint, the eval
will be removed in v0.8
node_modules/@blocksuite/blocks/dist/databaseUse of eval in "node_modules/flexsearch/dist/flexsearch.bundle.js" is strongly discouraged as it poses security risks and may cause issues with minification
https://github.com/nextapps-de/flexsearch/blob/9abb781357f04e7db8529654c6941009771f4bf1/src/worker/index.js#L138
https://rollupjs.org/troubleshooting/#avoiding-eval