diff --git a/rollup.config.js b/rollup.config.js index 16e93a8991..5f8190d923 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -3,7 +3,7 @@ import { terser } from 'rollup-plugin-terser'; import rollupReplace from 'rollup-plugin-replace'; import fileSize from 'rollup-plugin-filesize'; -const createConfig = ({ input, output }) => ({ +const createConfig = ({ input, output, target }) => ({ input, output, plugins: [ @@ -14,11 +14,14 @@ const createConfig = ({ input, output }) => ({ clean: true, tsconfigOverride: { compilerOptions: { - declaration: false + declaration: false, + ...(target ? { target } : {}) } } }), - terser(), + terser({ + toplevel: true, + }), fileSize() ] }); @@ -47,5 +50,13 @@ export default [ format: 'umd', name: 'XStateInterpreter' } + }), + createConfig({ + input: 'src/index.ts', + output: { + file: 'dist/xstate.web.js', + format: 'esm' + }, + target: 'ES2015' }) ]; diff --git a/src/StateNode.ts b/src/StateNode.ts index 2945300ae5..ce6cb81af2 100644 --- a/src/StateNode.ts +++ b/src/StateNode.ts @@ -89,8 +89,7 @@ const createDefaultOptions = (): MachineOptions => ({ guards: EMPTY_OBJECT }); -export const IS_PRODUCTION = - typeof process !== 'undefined' ? process.env.NODE_ENV === 'production' : true; +export const IS_PRODUCTION = process.env.NODE_ENV === 'production'; class StateNode< TContext = DefaultContext,