Skip to content

Commit

Permalink
feat(jsii): enable source maps for declaration files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrestone committed May 6, 2022
1 parent 8eec086 commit 53bdfb6
Show file tree
Hide file tree
Showing 33 changed files with 68 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/@fixtures/jsii-calc-bundled/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ node_modules/
coverage/

!index.js
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/benchmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
output.txt
*.d.ts
*.js
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/check-node/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/dotnet-runtime-test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ node_modules/
.nyc_output/
coverage/
.nuget/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/dotnet-runtime/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ obj/

# consumed by generate.sh
!*.t.js
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/go-runtime-test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

# Ignore our test files
project/compliance-report.json
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/go-runtime/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.d.ts

!jsii-runtime-go/internal/kernel/process/jsii-mock-runtime.js
*.d.ts.map
2 changes: 2 additions & 0 deletions packages/@jsii/integ-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.env
*.js
*.d.ts
*.d.ts.map
2 changes: 1 addition & 1 deletion packages/@jsii/integ-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"build": "tsc --build && npm run lint",
"lint": "eslint . --ext .ts --ignore-path=.gitignore",
"lint": "eslint . --ext .ts --ignore-pattern '*.d.ts' --ignore-path=.gitignore",
"lint:fix": "yarn lint --fix",
"test:integ": "jest",
"package": "package-private"
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/integ-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"composite": false,
"declaration": false
"declaration": true
},
"extends": "../../../tsconfig-base",
"include": ["**/*.ts"],
Expand Down
1 change: 1 addition & 0 deletions packages/@jsii/java-runtime/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.d.ts
!*.t.js
maven-repo
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/kernel/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/runtime/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules/
coverage/

test/_tarballs/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@jsii/spec/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ schema
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@scope/jsii-calc-base-of-base/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@scope/jsii-calc-base/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ dist
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/@scope/jsii-calc-lib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist/
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/codemaker/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ typings/


# End of https://www.gitignore.io/api/node
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-calc/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.d.ts
node_modules/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-diff/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules/
coverage/

lib/version.ts
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-pacmak/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ node_modules/
coverage/

test/expected.*/dotnet/**/obj/Debug
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-reflect/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ coverage
node_modules

!jest.config.js
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-rosetta/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
node_modules
*.d.ts
coverage
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii-rosetta/lib/typescript/ts-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const STANDARD_COMPILER_OPTIONS: ts.CompilerOptions = {
alwaysStrict: true,
charset: 'utf8',
declaration: true,
declarationMap: true,
experimentalDecorators: true,
inlineSourceMap: true,
inlineSources: true,
Expand Down
1 change: 1 addition & 0 deletions packages/jsii/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ coverage/
README.md

lib/version.ts
*.d.ts.map
1 change: 1 addition & 0 deletions packages/jsii/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const BASE_COMPILER_OPTIONS: ts.CompilerOptions = {
alwaysStrict: true,
charset: 'utf8',
declaration: true,
declarationMap: true,
experimentalDecorators: true,
incremental: true,
inlineSourceMap: true,
Expand Down
24 changes: 24 additions & 0 deletions packages/jsii/test/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ describe(Compiler, () => {
removeSync(sourceDir);
}
});

test('emits declaration map', () => {
const sourceDir = mkdtempSync(join(tmpdir(), 'jsii-tmpdir'));

try {
writeFileSync(join(sourceDir, 'index.ts'), 'export class MarkerA {}');

const compiler = new Compiler({
projectInfo: {
..._makeProjectInfo(sourceDir, 'index.d.ts'),
},
generateTypeScriptConfig: 'tsconfig.jsii.json',
});

compiler.emit();

expect(() => {
readFileSync(join(sourceDir, 'index.d.ts.map'), 'utf-8');
}).not.toThrow();
} finally {
removeSync(sourceDir);
}
});
});

function _makeProjectInfo(sourceDir: string, types: string): ProjectInfo {
Expand Down Expand Up @@ -180,6 +203,7 @@ function expectedTypeScriptConfig() {
charset: 'utf8',
composite: false,
declaration: true,
declarationMap: true,
experimentalDecorators: true,
incremental: true,
inlineSourceMap: true,
Expand Down
24 changes: 12 additions & 12 deletions packages/jsii/test/deprecated-remover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ test('produces correct output', () => {
export * from './retained';
export * from './enums';
export { GrandChild, Retained } from './mixed';
//////////////////
//# sourceMappingURL=index.d.ts.map//////////////////
///////////////////////
/// deprecated.d.ts ///
///////////////////////
//# sourceMappingURL=deprecated.d.ts.map///////////////////////
/////////////////////
Expand All @@ -127,15 +127,15 @@ test('produces correct output', () => {
}
export declare class RetainedClass {
}
/////////////////////
//# sourceMappingURL=retained.d.ts.map/////////////////////
//////////////////
/// enums.d.ts ///
export declare enum SomeEnum {
VALUE_RETAINED = 0
}
//////////////////
//# sourceMappingURL=enums.d.ts.map//////////////////
//////////////////
Expand All @@ -148,7 +148,7 @@ test('produces correct output', () => {
export declare class GrandChild extends Retained implements retained_1.IRetainedInterface {
retainedMethod(): void;
}
//////////////////
//# sourceMappingURL=mixed.d.ts.map//////////////////
"
`);
});
Expand Down Expand Up @@ -177,12 +177,12 @@ test('cross-file deprecated heritage', () => {
import './deprecated';
export interface INotDeprecated {
}
//////////////////
//# sourceMappingURL=index.d.ts.map//////////////////
///////////////////////
/// deprecated.d.ts ///
///////////////////////
//# sourceMappingURL=deprecated.d.ts.map///////////////////////
"
`);
});
Expand Down Expand Up @@ -452,15 +452,15 @@ describe('stripDeprecatedAllowList', () => {
export * from './retained';
export * from './enums';
export { Deprecated, GrandChild, Retained } from './mixed';
//////////////////
//# sourceMappingURL=index.d.ts.map//////////////////
///////////////////////
/// deprecated.d.ts ///
/** @deprecated stripped */
export declare class DeprecatedClass {
}
///////////////////////
//# sourceMappingURL=deprecated.d.ts.map///////////////////////
/////////////////////
Expand All @@ -469,7 +469,7 @@ describe('stripDeprecatedAllowList', () => {
}
export declare class RetainedClass {
}
/////////////////////
//# sourceMappingURL=retained.d.ts.map/////////////////////
//////////////////
Expand All @@ -482,7 +482,7 @@ describe('stripDeprecatedAllowList', () => {
VALUE_ONE = 0,
VALUE_TWO = 1
}
//////////////////
//# sourceMappingURL=enums.d.ts.map//////////////////
//////////////////
Expand All @@ -499,7 +499,7 @@ describe('stripDeprecatedAllowList', () => {
export declare class GrandChild extends Deprecated {
retainedMethod(): void;
}
//////////////////
//# sourceMappingURL=mixed.d.ts.map//////////////////
"
`);
});
Expand Down
1 change: 1 addition & 0 deletions packages/jsii/vendor/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
!*.d.ts
*.d.ts.map
1 change: 1 addition & 0 deletions packages/oo-ascii-tree/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ coverage
node_modules

!jest.config.js
*.d.ts.map
1 change: 1 addition & 0 deletions tools/jsii-build-tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
node_modules/
.nyc_output/
coverage/
*.d.ts.map
1 change: 1 addition & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"strictPropertyInitialization": true, /* Require all properties be initialized in the constructor. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"declarationMap": true, /* Generates declaration map '.d.ts.map' file. */
"esModuleInterop": false, /* Turn on babel and typesystem compatibility with ES modules */
"inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
"inlineSources": true, /* Emit the source alongside the sourcemaps within a single file. */
Expand Down

0 comments on commit 53bdfb6

Please sign in to comment.