Does process.cwd() work?
Hi, you might already be aware of this. I can't get process.cwd() to work and I'm not sure if there is a missing option I need to pass in for it to work. I can see that it exists in the source code. I think this is probably an issue from rollup-plugin-node-polyfills because it doesn't work in that either.
After setting up rollup and the required plugins it doesn't polyfill process.cwd().
// rollup.config.js
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import nodePolyfills from 'rollup-plugin-polyfill-node';
export default [{
input: 'src/index.ts',
output: {
file: 'dist/index.js',
format: 'cjs',
name: 'code'
},
plugins: [
typescript(),
nodePolyfills(),
commonjs()
]
}];
// src/index.ts
console.log(process.cwd())
// dist/index.js
'use strict';
console.log(process.cwd());
This plugin only polyfills node native modules, not globals
Hi @remorses, so just to confirm it doesn't polyfill process? Because the readme suggests it does.
Hi @gavinmcfarland - did you get anywhere with this? facing the same issue
It was a while since I looked at it, but I think I did get it working, I remember something about the documentation being hard to understand.
I might have done...
export default [{
// ...
plugins: [
typescript(),
nodePolyfills({ include: null}),
commonjs()
]
}];
Or I might have passed in {process: true}. The original repo suggests you can turn individual built-ins on and off.
https://github.com/ionic-team/rollup-plugin-node-polyfills