openworm / geppetto-application

Sample Geppetto application
http://geppetto.org
Other
3 stars 1 forks source link

Problem to import right version of a module with webpack #16

Open rodriguez-facundo opened 5 years ago

rodriguez-facundo commented 5 years ago

If we are working in geppetto-application and we want to try a new version of a package (I tried with pixi.js from 4.2.0 to 5.0.4), it does not work. The import keeps defaulting to 4.2.0. That is because we are instructing webpack to first look for modules in geppetto-client node_modules folder.

// webpack.config.js Line 132
modules: [
        path.resolve(__dirname, geppetto_client_path, 'node_modules'), 
        'node_modules'
      ],

Fix:

Inverting the sequence will give us the right module version. But now we have the same issue in the opposite order (if we work in development mode, and we install a new version of an existing package in geppetto-client, then we wont be able to import it properly because it will be found first in geppetto-application node_module folder).

// webpack.config.js Line 132
modules: [
        'node_modules',
        path.resolve(__dirname, geppetto_client_path, 'node_modules'), 
      ],

The problem appears when changing versions of an existing package, but it does not affect when installing new packages.

Example:

npm list pixi.js
>nwb-explorer@0.2.0 /Users/snakes/Desktop/nwb-explorer/webapp
>├─┬ @geppettoengine/geppetto-client@1.0.0 (github:openworm/geppetto-client#5b89ce377e2d242d93b23ac784a2bc5479e6ee65)
>│ └── pixi.js@4.2.3
>└── pixi.js@5.0.4

With abs path:

ImageViewer.js:11 Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_2_pixi_js__.Application is not a function

With relative paths:

Screenshot 2019-07-17 at 6 24 58 PM
tarelli commented 5 years ago

https://medium.com/p/61befa5aaca7