Yoast / YoastSEO.js

Analyze content on a page and give SEO feedback as well as render a snippet preview.
GNU General Public License v3.0
403 stars 172 forks source link

Published package does not work in a standalone environment #2231

Open jcomack opened 4 years ago

jcomack commented 4 years ago

What did you expect to happen?

While attempting to implement the Yoast SEO package in a Node.js environment, I expected to be able to run it without errors.

What happened instead?

While attempting to run my own script (i.e. node index.js ), I was presented with the following error:

/Users/theuser/projectdir/node_modules/yoastseo/index.js:1
(function (exports, require, module, __filename, __dirname) { import { AnalysisWebWorker, AnalysisWorkerWrapper, createWorker } from "./src/worker";

SyntaxError: Unexpected token {

Please note: This issue occurs because the index.js file in the package does not get Bablified, but it should.

How can we reproduce this behavior?

// Altered the import to this to ensure compatibility with Node.
const { Paper, Researcher } = require( "yoastseo" );

const paper = new Paper( "Text to analyze", {
    keyword: "analyze",
} );
const researcher = new Researcher( paper );

console.log( researcher.getResearch( "wordCountInText" ) );

Technical info

Which browser is affected (or browsers):