| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…itted into single out)
|
Mohamed Hegazy (@mhegazy) Do you want to look at this at this point? I've got js and dts concatenation in. |
Sorry, something went wrong.
There was a problem hiding this comment.
my only comment here, is we can simplify this using the resolver to get the symbol and then use the symbol's declaration filename to get the semiAbsolutePath,
here is what i had in mind.
function emitExternalModuleSpecifier(moduleSpecifier: Expression) {
Debug.assert(moduleSpecifier.kind === SyntaxKind.StringLiteral);
if (compilerOptions.out) {
let moduleSymbol = resolver.getSymbolAtLocation(moduleSpecifier);
if (moduleSymbol && moduleSymbol.valueDeclaration &&
moduleSymbol.valueDeclaration.kind === SyntaxKind.SourceFile &&
!isDeclarationFile(<SourceFile>moduleSymbol.valueDeclaration)) {
let nonRelativeModuleName = getExternalModuleNameFromPath((<SourceFile>moduleSymbol.valueDeclaration).fileName);
write("\"");
write(nonRelativeModuleName);
write("\"");
return;
}
}
writeTextOfNode(currentSourceFile, moduleSpecifier);
}
function getExternalModuleNameFromPath(fileName: string) {
let sourceFilePath = getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
let commonSourceDirectory = host.getCommonSourceDirectory();
sourceFilePath = sourceFilePath.replace(commonSourceDirectory, "");
return removeFileExtension(sourceFilePath);
}
Sorry, something went wrong.
|
Once this goes in, please update the breaking change page: https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes Add a snippit about it in What's new page: https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#typescript-18-upcoming And update the documentation for compiler options in: https://github.com/Microsoft/TypeScript/wiki/Compiler-Options |
Sorry, something went wrong.
--outFile & --module concatenation
|
Is this still only amd/systemjs? If so the statement in roadmap https://github.com/Microsoft/TypeScript/wiki/Roadmap#18 Concatenate module output with --outFile seems misleading. |
Sorry, something went wrong.
|
Is concatenating node/commonjs modules an interesting/common scenario? |
Sorry, something went wrong.
Not really. In all honesty just as interesting as amd, none of these bundlings are likely to happen in isolation i.e. module authors expect these modules to be consumed by users that will do bundling themselves, bundling the module code along with the app code. Was just curious. Thanks for the clarification 🌹 |
Sorry, something went wrong.
|
there is definately need for this in commonjs/amd: https://github.com/TypeStrong/dts-bundle
|
Sorry, something went wrong.
|
Reio Piller (@hypno2000) this is covered by #4433 |
Sorry, something went wrong.
|
I don't understand; can we concatenate commonjs modules into a single file now, or are they still all segmented? |
Sorry, something went wrong.
|
This is a year old PR, I would say open a new issue instead. And, no; common js modules can not be concatenated. |
Sorry, something went wrong.
|
Hey Wesley Wigham (@weswigham) eg. export function add(i: number, i2: number) {
return i + i2;
}
compiled with --outFile define("thing", ["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
function add(i, i2) {
return i + i2;
}
exports.add = add;
});
I want the same define("thing", ["require", "exports"]... without --outFile so I can concat the files together myself later in the build system. Is it possible? |
Sorry, something went wrong.
|
Alex Eagle (@alexeagle) Per our docs, you can add a ///<amd-module name="NamedModule"/> directive to the top of each file to name it. |
Sorry, something went wrong.
|
I don't want TypeScript authors to be aware of the module system used (this would be for karma, but for other bundlers I'd use ESM modules). Ideally I'd like the module names chosen the same way they are for --outFile |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
With this we support simple concatenation of amd and systemjs modules into the specified output file. ES6, UMD, and Commonjs all can't be bundled to via simple concatenation and path correction, so they are not a part of this change and it is an error to attempt to use one of them with --outFile.UMD was original on the list of formats to accept... but I realized that was silly when UMD contains support for commonjs (in addition to AMD), which we couldn't support - it seems silly to emit UMD when it only works in an AMD environment.
Since we use --out with --module commonjs internally (a lot), this changed the baselines for many tests.
This is, in effect, an alternative to #4754 which works for a handful of our module emits and doesn't require the user tell us an entrypoint.
Mohamed Hegazy (@mhegazy) care to give input?