Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Published package does not work in a standalone environment #2231

Description

@jcomack

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?

  • Create an empty, standalone environment in a new directory.
  • Run yarn init and go through all the steps.
  • Run yarn add yoastseo.
  • Create a new file in the directory named index.js and paste the following code in the file:
// 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" ) );
  • Run node index.js.
  • See error appear.

Technical info

  • Platform: Standalone
  • Platform version:
  • Yoast SEO version: 1.64.0

Which browser is affected (or browsers):

  • Chrome
  • Firefox
  • Safari
  • Other

If relevant, which editor is affected (or editors):

  • Classic Editor
  • Gutenberg
  • Classic Editor plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions