Skip to content

Commit cf3cd55

Browse files
authored
chore: fix minimatch imports (#27116)
For technical reasons, the way we were importing `minimatch` works in the current version of TypeScript, but is actually illegal according to the ESM spec. This poses problems when running `aws-cdk-lib` through `esbuild`. Update to a different import style that is correct in both. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8c76349 commit cf3cd55

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/aws-cdk-lib/core/lib/fs/ignore.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as path from 'path';
22
import dockerIgnore, * as DockerIgnore from '@balena/dockerignore';
33
import gitIgnore, * as GitIgnore from 'ignore';
4-
import * as minimatch from 'minimatch';
54
import { CopyOptions, IgnoreMode } from './options';
65

6+
// Must be a 'require' to not run afoul of ESM module import rules
7+
// eslint-disable-next-line @typescript-eslint/no-require-imports
8+
const minimatch = require('minimatch');
9+
710
/**
811
* Represents file path ignoring behavior.
912
*/

packages/aws-cdk-lib/core/lib/stack.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
33
import { IConstruct, Construct, Node } from 'constructs';
4-
import * as minimatch from 'minimatch';
54
import { Annotations } from './annotations';
65
import { App } from './app';
76
import { Arn, ArnComponents, ArnFormat } from './arn';
@@ -23,6 +22,10 @@ import * as cxschema from '../../cloud-assembly-schema';
2322
import { INCLUDE_PREFIX_IN_UNIQUE_NAME_GENERATION } from '../../cx-api';
2423
import * as cxapi from '../../cx-api';
2524

25+
// Must be a 'require' to not run afoul of ESM module import rules
26+
// eslint-disable-next-line @typescript-eslint/no-require-imports
27+
const minimatch = require('minimatch');
28+
2629
const STACK_SYMBOL = Symbol.for('@aws-cdk/core.Stack');
2730
const MY_STACK_CACHE = Symbol.for('@aws-cdk/core.Stack.myStack');
2831

0 commit comments

Comments
 (0)