Issue
Build environment
@polymer/polymer: 3.1.0
polymer-cli: 1.9.6
Steps to reproduce
npm i @splitsoftware/splitio@10.6.0
Import via es module: import { SplitFactory } from '@splitsoftware/splitio';
run polymer build
The following error appears:
Error: ENOENT: no such file or directory, open '/Users/[USER_NAME]/projects/[PROJECT_NAME]/frontend/events'
Answer
The way Polymer is performing the build differs significantly from webpack and other bundlers that can recognize the right path for an isomorphic app.
Polymer is trying to load the Node code path of the SDK, which in turn tries to import the events module from NodeJS.
Taking a look to what's on node_modules\@splitsoftware\splitio folder, you'll see a few package.json files with this format:
{
"main": "./node.js",
"browser": "./browser.js"
}
What we do there is tell NodeJS to just run the Node version of that module (the main field), while we tell bundlers to use the "Browser version".
If the plan is to implement the JS SDK in both server and browser modes, make sure to set the browser and main values to the corresponding js code.
Comments
0 comments
Please sign in to leave a comment.