Skip to content

Commit

Permalink
chore: fix minimatch imports (#27116)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
rix0rrr committed Sep 13, 2023
1 parent 8c76349 commit cf3cd55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/core/lib/fs/ignore.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import * as path from 'path';
import dockerIgnore, * as DockerIgnore from '@balena/dockerignore';
import gitIgnore, * as GitIgnore from 'ignore';
import * as minimatch from 'minimatch';
import { CopyOptions, IgnoreMode } from './options';

// Must be a 'require' to not run afoul of ESM module import rules
// eslint-disable-next-line @typescript-eslint/no-require-imports
const minimatch = require('minimatch');

/**
* Represents file path ignoring behavior.
*/
Expand Down
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/core/lib/stack.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import { IConstruct, Construct, Node } from 'constructs';
import * as minimatch from 'minimatch';
import { Annotations } from './annotations';
import { App } from './app';
import { Arn, ArnComponents, ArnFormat } from './arn';
Expand All @@ -23,6 +22,10 @@ import * as cxschema from '../../cloud-assembly-schema';
import { INCLUDE_PREFIX_IN_UNIQUE_NAME_GENERATION } from '../../cx-api';
import * as cxapi from '../../cx-api';

// Must be a 'require' to not run afoul of ESM module import rules
// eslint-disable-next-line @typescript-eslint/no-require-imports
const minimatch = require('minimatch');

const STACK_SYMBOL = Symbol.for('@aws-cdk/core.Stack');
const MY_STACK_CACHE = Symbol.for('@aws-cdk/core.Stack.myStack');

Expand Down

0 comments on commit cf3cd55

Please sign in to comment.