Skip to content

Commit

Permalink
Allow javascript modules to also have template literals minified (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: Alberto A Ayala <albertoaayala@Albertos-MBP.hsd1.il.comcast.net>
Co-authored-by: Max Milton <max@happycode.ltd>
  • Loading branch information
3 people committed Apr 10, 2022
1 parent 646b484 commit 0da1560
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function minify(code: string, opts: MinifyOptions = {}): MagicString {
next: true,
loc: true,
ranges: true,
module: true,

onComment(type, value, _start, _end, loc) {
if (
Expand Down
8 changes: 8 additions & 0 deletions test/minifyTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ let d = \` <!--<br> <br> <br>--> \`;`;
);
});

// Module javascript

test('minifies module javascript', () => {
const mockBuildResult = createMockBuildResult('export const a = `x y`;');
void esbuildTestHarness(minifyTemplates(), mockBuildResult);
assert.fixture(getOutput(mockBuildResult), 'export const a = `x y`;');
});

// JS sourcemaps

test('generates a new sourcemap', () => {
Expand Down

0 comments on commit 0da1560

Please sign in to comment.