FredKSchott / FredKSchott/rollup-plugin-polyfill-node

Does process.cwd() work?

Open
#12 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
193
Forks
60
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/snowpackjs/rollup-plugin-polyfill-node/blob/91de3e28ccf44dd318152e93603afabcb15ce8a4/polyfills/process-es6.js#L158.). 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()`.

```js
// 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()
]
}];
```

```js
// src/index.ts

console.log(process.cwd())
```

```js
// dist/index.js

'use strict';

console.log(process.cwd());
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.