-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
[rstream] in the web worker scope #425
Comments
I don't know enough about your project setup, but I've not once run into any issues with using any of the packages in a worker. There's no reliance on any globals, so my guess this is a config issue with esbuild (sorry, no 1st hand experience with it, only via Vite). Can you please put up a small project somewhere for debugging/reproduction? |
- also check for `import.meta.env.UMBRELLA_ASSERTS` for non-ViteJS tooling - btw. this is **not** a fix for the esbuild issue in #425 (but part of its solution posted in comments)
- also check for `import.meta.env.UMBRELLA_GLOBALS` for non-ViteJS tooling - btw. this is **not** a fix for the esbuild issue in #425 (but part of its solution posted in comments)
@bit-app-3000 After a lot of digging, I found that Plugin: // plugin-import-meta-env.js
import { readFileSync } from "fs";
export default (prefixes = []) => ({
name: "import.meta.env",
setup({ onLoad }) {
// only collect & expose selected (deemed safe!) env vars
const env = { MODE: process.env.NODE_ENV };
if (prefixes.length) {
for (let k of Object.keys(process.env)) {
if (prefixes.some((prefix) => k.startsWith(prefix))) {
env[k] = process.env[k];
}
}
}
const envFmt = `(${JSON.stringify(env)})`;
// plugin hook (only apply to JS/TS files)
onLoad({ filter: /\.[jt]sx?$/, namespace: "file" }, (args) => {
const code = readFileSync(args.path, "utf8").replace(
/\bimport\.meta\.env\b/g,
envFmt
);
return { contents: code };
});
},
}); Then use a import { build } from "esbuild";
import pluginImportMetaEnv from "./plugin-import-meta-env.js";
await build({
entryPoints: ["src/app.js", "src/store.js"],
bundle: true,
minify: true,
outdir: "build",
// can skip the looking for custom UMBRELLA prefix if you're just after using default behavior
plugins: [pluginImportMetaEnv(["UMBRELLA_"])],
}); ...and build via: I've pushed some new releases (incl. the above linked commits), so also make sure to update your dependencies, just in case... |
thx for the help
|
Cool. Good to know... |
worker.js (esm) esbuild
The text was updated successfully, but these errors were encountered: