VSCode works but native package does not
barrett-ruth opened this issue · 1 comments
barrett-ruth commented
I don't use VSCode but installed it to test that import-cost does indeed work:
However, I cannot seem to get the package working despite my best efforts.
In a new directory, I do the following:
yarn add react
- Create a file
react_imports.jsx
with the following contents:
import React from "react";
- Open VSCode.
- import-cost works correctly.
I then create a script script.js
and then attempt to run it with the following steps:
- 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));
- Install the dependencies with
yarn add import-cost vscode-uri native-fs-adapter fs-extra
- Run the script with
node script.js
Then, all I get is the following result:
Any help is appreciated. If there is a way to show debug logs let me know and I will supply.
barrett-ruth commented
Issue resolved. Solution: RTFM