Socket
Socket
Sign inDemoInstall

rollup-plugin-dts

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-dts - npm Package Compare versions

Comparing version 1.1.9 to 1.1.10

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### 1.1.10 2019-10-03
- fix trailing comments being removed from rendered chunks
- fix issues with multiple inline-imports
### 1.1.9 2019-10-03

@@ -2,0 +7,0 @@

59

dist/rollup-plugin-dts.js

@@ -135,3 +135,3 @@ 'use strict';

fix() {
let code = this.sourceFile.getText();
let code = this.sourceFile.getFullText();
const { namespaces, itemTypes } = this.findNamespaces();

@@ -520,3 +520,2 @@ for (const ns of namespaces) {

}
const original = this.transformer.sourceFile.text.slice(start, end);
const middle = start + newModifiers.length;

@@ -526,5 +525,4 @@ this.pushRaw(removeNested({ start: middle, end }));

this.transformer.fixups.push({
original,
range: { start, end: middle },
replaceWith: newModifiers,
range: { start, end: middle },
});

@@ -728,3 +726,3 @@ }

}, range);
this.transformer.pushStatement({
this.transformer.unshiftStatement({
type: "ImportDeclaration",

@@ -853,4 +851,19 @@ specifiers: [

this.fixups = [];
this.typeReferences = new Set();
this.declarations = new Map();
this.exports = new Set();
// collect all the type references and create fixups to remove them from the code,
// we will add all of these later on to the whole chunk…
const lineStarts = sourceFile.getLineStarts();
for (const ref of sourceFile.typeReferenceDirectives) {
this.typeReferences.add(ref.fileName);
const { line } = sourceFile.getLineAndCharacterOfPosition(ref.pos);
const start = lineStarts[line];
const end = sourceFile.getLineEndOfPosition(ref.pos);
this.fixups.push({
range: { start, end },
// just overwrite them with whitespace, which will get compressed later on anyway :-)
replaceWith: " ".repeat(end - start),
});
}
this.ast = createProgram(sourceFile);

@@ -862,15 +875,21 @@ for (const stmt of sourceFile.statements) {

transform() {
return { ast: this.ast, fixups: this.fixups };
return {
ast: this.ast,
fixups: this.fixups,
typeReferences: this.typeReferences,
};
}
addFixupLocation(range) {
const original = this.sourceFile.text.slice(range.start, range.end);
let identifier = `ɨmport${this.fixups.length}`;
let identifier = `_mp_rt${this.fixups.length}`;
identifier += original.slice(identifier.length).replace(/[^a-zA-Z0-9_$]/g, () => "_");
this.fixups.push({
range,
replaceWith: identifier,
original,
range,
});
return identifier;
}
unshiftStatement(node) {
this.ast.body.unshift(withStartEnd(node, { start: 0, end: 0 }));
}
pushStatement(node) {

@@ -1122,12 +1141,13 @@ this.ast.body.push(node);

function transformFile(input) {
for (const ref of input.typeReferenceDirectives) {
typeReferences.add(ref.fileName);
let code = input.getFullText();
const transformer = new Transformer(input);
const output = transformer.transform();
for (const ref of output.typeReferences) {
typeReferences.add(ref);
}
const transformer = new Transformer(input);
const { ast, fixups } = transformer.transform();
let code = input.getFullText();
for (const fixup of fixups) {
// apply fixups, which means replacing certain text ranges before we hand off the code to rollup
for (const fixup of output.fixups) {
code = code.slice(0, fixup.range.start) + fixup.replaceWith + code.slice(fixup.range.end);
}
return { code, ast };
return { code, ast: output.ast };
}

@@ -1201,6 +1221,9 @@ return {

renderChunk(code, chunk) {
const pragmas = Array.from(typeReferences, ref => `/// <reference types="${ref}" />\n`).join("");
const source = ts.createSourceFile(chunk.fileName, code, ts.ScriptTarget.Latest, true);
const fixer = new NamespaceFixer(source);
code = pragmas + fixer.fix();
code = Array.from(typeReferences, ref => `/// <reference types="${ref}" />`).join("\n");
if (code) {
code += "\n";
}
code += fixer.fix();
return { code, map: { mappings: "" } };

@@ -1207,0 +1230,0 @@ },

{
"name": "rollup-plugin-dts",
"version": "1.1.9",
"version": "1.1.10",
"description": "An experiment to generate .d.ts rollup files",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc