Skip to content

Commit

Permalink
fix(rollup): add process.env to rollup
Browse files Browse the repository at this point in the history
Packages using a-msgpack that don't define process.env encounter an
error because utf8.ts uses process.env.TEXT_ENCODING to determine the
usage of the TextEncoding API.
Add this process.env in the rollup config.
  • Loading branch information
earnestwheeler committed Mar 29, 2023
1 parent ae2f03d commit 97302ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/a-msgpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@arista/prettier-config": "1.1.4",
"@rollup/plugin-commonjs": "22.0.2",
"@rollup/plugin-node-resolve": "13.3.0",
"@rollup/plugin-replace": "4.0.0",
"@rollup/plugin-typescript": "8.5.0",
"@types/base64-js": "1.3.0",
"@types/jest": "27.5.2",
Expand Down
12 changes: 12 additions & 0 deletions packages/a-msgpack/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import { terser } from 'rollup-plugin-terser';

Expand Down Expand Up @@ -43,6 +44,17 @@ if (env === 'development' || env === 'production') {
globals,
name: 'a-msgpack',
};
config.plugins.push(
replace({
preventAssignment: true,
values: {
'process.env.NODE_ENV': JSON.stringify(env),
'process.env.TEXT_ENCODING': JSON.stringify('always'),
'process.env.TEXT_DECODER': JSON.stringify('always'),
},
}),
commonjs(),
);
}

if (env === 'production') {
Expand Down

0 comments on commit 97302ce

Please sign in to comment.