Skip to content

Conversation

@rjmunro
Copy link
Contributor

@rjmunro rjmunro commented Oct 8, 2025

About the Contributor

Type of Contribution

This is a Bug fix / Code improvement for compatibility with later node versions

Current Behavior

Using import with a json file is banned in node 20 unless you use with { type: 'json' }, which is not supported in node 16, our current build target.

Question: Does using import freeze the value at sofie-core build time, not reflect the version that yarn has chosen to install? If so, is that the right thing to do?

New Behavior

Use require to import the package.json file.

Testing

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Affected areas

This PR affects building blueprints.

Time Frame

  • Not urgent, but we would like to get this merged into the in-development release.

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Julusian
Copy link
Member

Julusian commented Oct 8, 2025

I'm wondering where/how this is an issue, as these libs officially only suport node22+ in release52+.

"engines": {
"node": ">=22.20.0"
},

The build config might be doing so with support for older, but that will be changed whenever someone feels like it (it often lags a bit behind)

The latest r53 build of this file (from https://www.npmjs.com/package/@sofie-automation/shared-lib/v/1.53.0-nightly-release53-20250924-143640-007a9da.0?activeTab=code) is:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSR_VERSION = exports.TSR = void 0;
const tslib_1 = require("tslib");
const TSR = tslib_1.__importStar(require("timeline-state-resolver-types"));
exports.TSR = TSR;
const tsrPkgInfo = tslib_1.__importStar(require("timeline-state-resolver-types/package.json"));
exports.TSR_VERSION = tsrPkgInfo.version;
//# sourceMappingURL=tsr.js.map

so I am curious what this PR will actually change

Without breaking node 16

This prevents the error:

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///Users/rjmunro/superflytv/sofie-timeline-state-resolver/packages/timeline-state-resolver-types/package.json" needs an import attribute of "type: json"
    at validateAttributes (node:internal/modules/esm/assert:88:15)
    at defaultLoadSync (node:internal/modules/esm/load:179:3)
    at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:379:24)
    at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:326:11)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1411:24)
    at Module._compile (node:internal/modules/cjs/loader:1544:5)
    at Object..js (node:internal/modules/cjs/loader:1699:10)
    at Module.load (node:internal/modules/cjs/loader:1313:32)
    at Function._load (node:internal/modules/cjs/loader:1123:12) {
  code: 'ERR_IMPORT_ATTRIBUTE_MISSING'

Which I got when trying to build blueprints using node 20 when I was 
yarn link`ed to sofie-core, rather than using a pre-built version.
@rjmunro rjmunro force-pushed the rjmunro/fix-package-import branch from db4bb4c to 7154a3f Compare October 8, 2025 14:52
@rjmunro rjmunro changed the title Fix determining TSR version when running in node 20 Fix determining TSR version when running in certain configurations Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants