wix/import-cost

VSCode works but native package does not

barrett-ruth opened this issue · 1 comments

I don't use VSCode but installed it to test that import-cost does indeed work:
image
However, I cannot seem to get the package working despite my best efforts.

In a new directory, I do the following:

  1. yarn add react
  2. Create a file react_imports.jsx with the following contents:
import React from "react";
  1. Open VSCode.
  2. import-cost works correctly.

I then create a script script.js and then attempt to run it with the following steps:

  1. Create a file script.js in the same directory with the following contents:
import { importCost, cleanup, Lang } from "import-cost";
import { readFileSync } from "fs";
import { resolve } from "path";

const fileName = resolve("react_imports.js");
const fileContents = readFileSync(fileName, { encoding: "utf-8", });
const emitter = importCost(fileName, fileContents, Lang.JAVASCRIPT);

emitter.on('start', packages => console.log(packages));
emitter.on('calculated', calculated => console.log(calculated));
emitter.on('done', packages => console.log(packages));
emitter.on('log', log => console.log(log));
  1. Install the dependencies with yarn add import-cost vscode-uri native-fs-adapter fs-extra
  2. Run the script with node script.js

Then, all I get is the following result:
image

Any help is appreciated. If there is a way to show debug logs let me know and I will supply.

Issue resolved. Solution: RTFM