From 5e3a6c5e63cfd63054a46dfbbbdbffa0313ffaf8 Mon Sep 17 00:00:00 2001 From: chentsulin Date: Mon, 6 May 2024 19:57:28 +0800 Subject: [PATCH 1/2] test: add test for import attributes --- test/fixtures/with-json.mjs | 9 +++++++++ test/hook/v19-static-import-with.mjs | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/fixtures/with-json.mjs create mode 100644 test/hook/v19-static-import-with.mjs diff --git a/test/fixtures/with-json.mjs b/test/fixtures/with-json.mjs new file mode 100644 index 0000000..60d43d1 --- /dev/null +++ b/test/fixtures/with-json.mjs @@ -0,0 +1,9 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License. +// +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. + +import coolFile from './something.json' with { type: 'json' } + +export default { + data: coolFile.data +} diff --git a/test/hook/v19-static-import-with.mjs b/test/hook/v19-static-import-with.mjs new file mode 100644 index 0000000..98f7b4a --- /dev/null +++ b/test/hook/v19-static-import-with.mjs @@ -0,0 +1,15 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License. +// +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. + +import Hook from '../../index.js' +import jsonMjs from '../fixtures/with-json.mjs' +import { strictEqual } from 'assert' + +Hook((exports, name) => { + if (name.match(/with-json\.mjs/)) { + exports.default.data += '-dawg' + } +}) + +strictEqual(jsonMjs.data, 'dog-dawg') From 4cda44424e2a9886f446bb4d13e21cec6399b1a5 Mon Sep 17 00:00:00 2001 From: chentsulin Date: Tue, 7 May 2024 13:03:53 +0800 Subject: [PATCH 2/2] fix: use v20.10 instead of v19 --- .../{v19-static-import-with.mjs => v20.10-static-import-with.mjs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/hook/{v19-static-import-with.mjs => v20.10-static-import-with.mjs} (100%) diff --git a/test/hook/v19-static-import-with.mjs b/test/hook/v20.10-static-import-with.mjs similarity index 100% rename from test/hook/v19-static-import-with.mjs rename to test/hook/v20.10-static-import-with.mjs