Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/build-tests/eslint-bulk-suppressions-test](./build-tests/eslint-bulk-suppressions-test/) | Sample code to test eslint bulk suppressions |
| [/build-tests/eslint-bulk-suppressions-test-flat](./build-tests/eslint-bulk-suppressions-test-flat/) | Sample code to test eslint bulk suppressions with flat configs |
| [/build-tests/eslint-bulk-suppressions-test-legacy](./build-tests/eslint-bulk-suppressions-test-legacy/) | Sample code to test eslint bulk suppressions for versions of eslint < 8.57.0 |
| [/build-tests/esm-node-import-test](./build-tests/esm-node-import-test/) | This project validates that importing a rushstack package from a 'type: module' Node.js project works correctly with the package.json 'exports' field. See https://github.com/microsoft/rushstack/issues/5644 |
| [/build-tests/hashed-folder-copy-plugin-webpack5-test](./build-tests/hashed-folder-copy-plugin-webpack5-test/) | Building this project exercises @rushstack/hashed-folder-copy-plugin with Webpack 5. NOTE - THIS TEST IS CURRENTLY EXPECTED TO BE BROKEN |
| [/build-tests/heft-copy-files-test](./build-tests/heft-copy-files-test/) | Building this project tests copying files with Heft |
| [/build-tests/heft-example-lifecycle-plugin](./build-tests/heft-example-lifecycle-plugin/) | This is an example heft plugin for testing the lifecycle hooks |
Expand Down
2 changes: 2 additions & 0 deletions apps/api-documenter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
"exports": {
".": {
"types": "./dist/rollup.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib-esm/index.js",
"require": "./lib-commonjs/index.js"
},
"./lib/*.schema.json": "./lib-commonjs/*.schema.json",
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
2 changes: 2 additions & 0 deletions apps/api-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
"exports": {
".": {
"types": "./dist/rollup.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib-esm/index.js",
"require": "./lib-commonjs/index.js"
},
"./lib/*.schema.json": "./lib-commonjs/*.schema.json",
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
1 change: 1 addition & 0 deletions apps/cpu-profile-summarizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"exports": {
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
2 changes: 2 additions & 0 deletions apps/heft/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
"exports": {
".": {
"types": "./dist/heft.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib-esm/index.js",
"require": "./lib-commonjs/index.js"
},
"./lib/*.schema.json": "./lib-commonjs/*.schema.json",
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
1 change: 1 addition & 0 deletions apps/lockfile-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"./lib/*.schema.json": "./lib-commonjs/*.schema.json",
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
2 changes: 2 additions & 0 deletions apps/playwright-browser-tunnel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
"exports": {
".": {
"types": "./lib-dts/index.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib-esm/index.js",
"require": "./lib-commonjs/index.js"
},
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
1 change: 1 addition & 0 deletions apps/rundown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"exports": {
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
2 changes: 2 additions & 0 deletions apps/rush-mcp-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
"exports": {
".": {
"types": "./dist/mcp-server.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib-esm/index.js",
"require": "./lib-commonjs/index.js"
},
"./lib/*.schema.json": "./lib-commonjs/*.schema.json",
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
1 change: 1 addition & 0 deletions apps/rush/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"exports": {
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
1 change: 1 addition & 0 deletions apps/trace-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"exports": {
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
2 changes: 2 additions & 0 deletions apps/zipsync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
"exports": {
".": {
"types": "./lib-dts/index.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib-esm/index.js",
"require": "./lib-commonjs/index.js"
},
"./lib/*": {
"types": "./lib-dts/*.d.ts",
"node": "./lib-commonjs/*.js",
"import": "./lib-esm/*.js",
"require": "./lib-commonjs/*.js"
},
Expand Down
3 changes: 3 additions & 0 deletions build-tests/esm-node-import-test/config/jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "local-node-rig/profiles/default/config/jest.config.json"
}
7 changes: 7 additions & 0 deletions build-tests/esm-node-import-test/config/rig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// The "rig.json" file directs tools to look for their config files in an external package.
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "local-node-rig"
}
20 changes: 20 additions & 0 deletions build-tests/esm-node-import-test/eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

const nodeProfile = require('local-node-rig/profiles/default/includes/eslint/flat/profile/node');
const friendlyLocalsMixin = require('local-node-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals');
const tsdocMixin = require('local-node-rig/profiles/default/includes/eslint/flat/mixins/tsdoc');

module.exports = [
...nodeProfile,
...friendlyLocalsMixin,
...tsdocMixin,
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
tsconfigRootDir: __dirname
}
}
}
];
20 changes: 20 additions & 0 deletions build-tests/esm-node-import-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "esm-node-import-test",
"description": "This project validates that importing a rushstack package from a 'type: module' Node.js project works correctly with the package.json 'exports' field. See https://github.com/microsoft/rushstack/issues/5644",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "heft test --clean",
"_phase:build": "heft run --only build -- --clean",
"_phase:test": "heft run --only test -- --clean"
},
"dependencies": {
"@rushstack/node-core-library": "workspace:*"
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
"eslint": "~9.37.0",
"local-node-rig": "workspace:*"
}
}
16 changes: 16 additions & 0 deletions build-tests/esm-node-import-test/src/start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import { Path } from '@rushstack/node-core-library';

export const EXPECTED_OUTPUT: string =
'ESM import test PASSED: @rushstack/node-core-library resolved correctly under Node.js ESM.';

// If this line runs without ERR_MODULE_NOT_FOUND, the exports map is working correctly.
const result: string = Path.convertToSlashes('foo\\bar');
if (result !== 'foo/bar') {
throw new Error('Unexpected result from Path.convertToSlashes: ' + result);
}

// eslint-disable-next-line no-console
console.log(EXPECTED_OUTPUT);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ESM Node Import Test should resolve @rushstack/node-core-library correctly under Node.js ESM 1`] = `
"ESM import test PASSED: @rushstack/node-core-library resolved correctly under Node.js ESM.
"
`;
28 changes: 28 additions & 0 deletions build-tests/esm-node-import-test/src/test/start.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { ChildProcess } from 'node:child_process';

import { Executable, PackageJsonLookup } from '@rushstack/node-core-library';

describe('ESM Node Import Test', () => {
it('should resolve @rushstack/node-core-library correctly under Node.js ESM', async () => {
const buildFolderPath: string | undefined = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
if (!buildFolderPath) {
throw new Error('Unable to determine build folder path for test script.');
}

const result: ChildProcess = Executable.spawn(process.execPath, [`${buildFolderPath}/lib-esm/start.js`], {
currentWorkingDirectory: buildFolderPath
});

const { stderr, stdout, exitCode, signal } = await Executable.waitForExitAsync(result, {
encoding: 'utf8'
});

expect(stderr).toBe('');
expect(stdout).toMatchSnapshot();
expect(exitCode).toBe(0);
expect(signal).toBeNull();
});
});
3 changes: 3 additions & 0 deletions build-tests/esm-node-import-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@microsoft/api-documenter"
}
],
"packageName": "@microsoft/api-documenter",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@microsoft/api-extractor-model"
}
],
"packageName": "@microsoft/api-extractor-model",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@microsoft/api-extractor"
}
],
"packageName": "@microsoft/api-extractor",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@microsoft/load-themed-styles"
}
],
"packageName": "@microsoft/load-themed-styles",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@microsoft/loader-load-themed-styles"
}
],
"packageName": "@microsoft/loader-load-themed-styles",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "none",
"packageName": "@microsoft/rush"
}
],
"packageName": "@microsoft/rush",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@microsoft/webpack5-load-themed-styles-loader"
}
],
"packageName": "@microsoft/webpack5-load-themed-styles-loader",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@rushstack/cpu-profile-summarizer"
}
],
"packageName": "@rushstack/cpu-profile-summarizer",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@rushstack/credential-cache"
}
],
"packageName": "@rushstack/credential-cache",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@rushstack/debug-certificate-manager"
}
],
"packageName": "@rushstack/debug-certificate-manager",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@rushstack/eslint-bulk"
}
],
"packageName": "@rushstack/eslint-bulk",
"email": "iclanton@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644.",
"type": "patch",
"packageName": "@rushstack/eslint-patch"
}
],
"packageName": "@rushstack/eslint-patch",
"email": "iclanton@users.noreply.github.com"
}
Loading