Closed nosy-b closed 6 years ago
I don't know about webpack, but I edited the tracking.js file to make it work on node with require('./tracking'). Here's it: https://github.com/SimoneS93/trackingjs
Having a similar problem here. I have installed the package via npm
, but it is impossible to include directly using import
or require
syntax.
It would be great if this module followed any of the JS module standards, but the most useful would probably be ES6 modules.
As @SimoneS93 noted, this is as simple as adding a module.exports
(CommonJS) or export
(ES6) statement to the end of the library.
Looks like they take pull requests ^^
you can try to use webpack shimming(https://webpack.js.org/guides/shimming/):
rules: [{
test: require.resolve('tracking'),
use: 'imports-loader?this=>window'
}],
plugins: [
new webpack.ProvidePlugin({
tracking: 'tracking'
})
]
is that currently supports ? :)
Hopefully this'll help someone.
I was running into the same problem importing tracking.js, and went the Webpack shim route as suggested by @geekplux , copying the code exactly as written, after installing the files via npm install tracking --save
.
When I imported tracking
, I found I also needed to import the libraries for ObjectTracker
. I thought I'd need to dive back into webpack.config.js
, but it worked just fine using:
import tracking from 'tracking';
import 'tracking/build/data/face-min.js';
import 'tracking/build/data/eye-min.js';
import 'tracking/build/data/mouth-min.js';
@jsprow Thank you for this!
Update for Parcel.js users:
import 'tracking'
import 'tracking/build/data/face-min.js'
import 'tracking/build/data/eye-min.js'
import 'tracking/build/data/mouth-min.js'
Thanks for this great library.
I wanted to use it in a web project built using webpack. In the package.json i added
which works fine, it's built and goes into node_modules. But how do you use it in a class?
import tracking from 'tracking';
doesn't work, nor the Require version (even with the build tracking.js placed into the sources) Thank you