Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite build: Unexpected keyword 'false' in service-factory.js #1372

Open
phlegx opened this issue May 26, 2023 · 5 comments
Open

Vite build: Unexpected keyword 'false' in service-factory.js #1372

phlegx opened this issue May 26, 2023 · 5 comments

Comments

@phlegx
Copy link

phlegx commented May 26, 2023

Hi!

I use Vite 4.x, Vue 3.x and @elastic/apm-rum-vue 2.1.2. Building the app I get this error:

[vite-plugin-pwa:build] Unexpected keyword 'false' (7:9) in /.../vue3/node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js
file: /.../vue3/node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js:7:9
5: import LoggingService from './logging-service';
6: import { CONFIG_CHANGE, CONFIG_SERVICE, LOGGING_SERVICE, APM_SERVER } from './constants';
7: import { __DEV__ } from '../state';
            ^
8: var serviceCreators = (_serviceCreators = {}, _serviceCreators[CONFIG_SERVICE] = function () {
9:   return new ConfigService();
file:///.../vue3/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:21186
  var err = new SyntaxError(message);
            ^

SyntaxError: Unexpected keyword 'false' (7:9) in /.../vue3/node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js

Is it a bug or a misconfiguration?

@luc-anise
Copy link

Having the same issue

@phlegx
Copy link
Author

phlegx commented May 2, 2024

Problem still exists. @luc-anise have you found a solution in the meantime?

@luc-anise
Copy link

luc-anise commented May 2, 2024

I was using vite and had a custom env variable for dev so I removed that and it worked

@phlegx
Copy link
Author

phlegx commented May 2, 2024

I use rollup plugin replace like described in the documentation https://www.elastic.co/guide/en/apm/agent/rum-js/current/install-the-agent.html#_rollup but it does not work. On build __DEV__ is always true.

plugins: [
  replace({
    'process.env.NODE_ENV': JSON.stringify('production')
  })
]
[commonjs--resolver] Unexpected keyword 'true' (9:9) in node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js
file: node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js:9:9
 7: import LoggingService from './logging-service';
 8: import { CONFIG_CHANGE, CONFIG_SERVICE, LOGGING_SERVICE, APM_SERVER } from './constants';
 9: import { true } from '../state';

If I build in production mode, then I get the same error but Unexpected keyword 'false'.

[commonjs--resolver] Unexpected keyword 'false' (9:9) in node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js
file: node_modules/@elastic/apm-rum-core/dist/es/common/service-factory.js:9:9
 7: import LoggingService from './logging-service';
 8: import { CONFIG_CHANGE, CONFIG_SERVICE, LOGGING_SERVICE, APM_SERVER } from './constants';
 9: import { false } from '../state';

@phlegx
Copy link
Author

phlegx commented May 2, 2024

How can I exclude apm-agent-rum-js from __DEV__ replacement, caused by vite-ssr module? vite-ssr uses the same naming __DEV__ and uses define: in Vite config. Maybe a more package specific naming like __ELASTIC_APM_RUM_DEV__ could be very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants