-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix minimizer renaming functions (#339)
- Loading branch information
Showing
3 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
const test = require('tap').test | ||
const webpack = require('webpack') | ||
const path = require('path') | ||
|
||
test('the library should work with webpack', async (t) => { | ||
t.plan(1) | ||
const targetdir = path.resolve(__dirname, '..', '.cache') | ||
const targetname = path.join(targetdir, 'webpacktest.js') | ||
const wopts = { | ||
entry: path.resolve(__dirname, '..', 'index.js'), | ||
mode: 'production', | ||
target: 'node', | ||
output: { | ||
path: targetdir, | ||
filename: 'webpacktest.js', | ||
library: { | ||
name: 'fastJsonStringify', | ||
type: 'umd' | ||
} | ||
} | ||
} | ||
await new Promise((resolve, reject) => { | ||
webpack(wopts, (err, stats) => { | ||
if (err) { reject(err) } else { resolve(stats) }; | ||
}) | ||
}) | ||
const build = require(targetname) | ||
const stringify = build({ | ||
title: 'webpack should not rename code to be executed', | ||
type: 'object', | ||
properties: { | ||
foo: { | ||
type: 'string' | ||
}, | ||
bar: { | ||
type: 'boolean' | ||
} | ||
}, | ||
patternProperties: { | ||
foo: { | ||
type: 'number' | ||
} | ||
} | ||
}) | ||
|
||
const obj = { foo: '42', bar: true } | ||
t.equal(stringify(obj), '{"foo":"42","bar":true}') | ||
}) |