Closed schester44 closed 4 years ago
ended up using the @rollup/plugin-replace
plugin to get around this.
import replace from "@rollup/plugin-replace";
plugins: [replace(envKeys())]
const envKeys = (envRaw) => {
return Object.keys(envRaw).reduce(
(envValues, envValue) => ({
...envValues,
[`process.env.${envValue}`]: JSON.stringify(envRaw[envValue])
}),
{}
);
};
Please can you send me a minimal conf that fails with core-js and babel, I need to test my update with such conf. Thanks
Give this a shot https://github.com/schester44/rollup-plugin-inject-process-env-reproduction
dev
script (yarn|npm run dev)The errors i'm seeing
[!] Error: Identifier 'process' has already been declared
node_modules/core-js/modules/es.promise.js (38:4)
36: var TypeError = global.TypeError;
37: var document = global.document;
38: var process = global.process;
^
39: var $fetch = getBuiltIn('fetch');
40: var newPromiseCapability = newPromiseCapabilityModule.f;
Error: Identifier 'process' has already been declared
Looks like its happening when I use @rollup/plugin-node-resolve
.. Maybe I need to exclude core-js from that?
resolve({
include: "node_modules/**",
})
Hi, there is a new version of the plugin, with a test that covers your issue.
I play it on you code, changing it with :
async function main() {
await Promise.resolve({});
}
console.log(process.env.ACCOUNT);
main();
Compile result :
$ ./node_modules/.bin/yarn run dev
rollup v2.6.1
bundles test.js → output.js...
created output.js in 2.9s
Running :
$ node output.js
test
I get an error when trying to use this plugin with core-js and babel's @babel/preset-env