mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
Merge branch 'master' into async-to-promises-helpers
This commit is contained in:
commit
e6136ebfaa
@ -33,6 +33,11 @@ const toReplacementExpression = (value, name) => {
|
||||
return [JSON.stringify(matches[2]), name];
|
||||
}
|
||||
|
||||
// --define @assign=Object.assign replaces expressions with expressions:
|
||||
if (name[0] === '@') {
|
||||
return [value, name.substring(1)];
|
||||
}
|
||||
|
||||
// --define A=1,B=true produces int/boolean literal:
|
||||
if (/^(true|false|\d+)$/i.test(value)) {
|
||||
return [value, name];
|
||||
|
||||
@ -1469,6 +1469,30 @@ exports[`fixtures build define with microbundle 5`] = `
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`fixtures build define-expression with microbundle 1`] = `
|
||||
"Used script: microbundle -f esm --no-sourcemap --define @Object.freeze=Object
|
||||
|
||||
Directory tree:
|
||||
|
||||
define-expression
|
||||
dist
|
||||
define-expression.js
|
||||
index.js
|
||||
package.json
|
||||
|
||||
|
||||
Build \\"defineExpression\\" to dist:
|
||||
56 B: define-expression.js.gz
|
||||
40 B: define-expression.js.br"
|
||||
`;
|
||||
|
||||
exports[`fixtures build define-expression with microbundle 2`] = `1`;
|
||||
|
||||
exports[`fixtures build define-expression with microbundle 3`] = `
|
||||
"console.log(Object({a:\\"b\\",c:\\"d\\"}));
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`fixtures build esnext-ts with microbundle 1`] = `
|
||||
"Used script: microbundle --raw
|
||||
|
||||
|
||||
1
test/fixtures/define-expression/index.js
vendored
Normal file
1
test/fixtures/define-expression/index.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
console.log(Object.freeze({ a: 'b', c: 'd' }));
|
||||
6
test/fixtures/define-expression/package.json
vendored
Normal file
6
test/fixtures/define-expression/package.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "define-expression",
|
||||
"scripts": {
|
||||
"build": "microbundle -f esm --no-sourcemap --define @Object.freeze=Object"
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,8 @@ const FIXTURES_DIR = `${__dirname}/fixtures`;
|
||||
const DEFAULT_SCRIPT = 'microbundle';
|
||||
const TEST_TIMEOUT = 11000;
|
||||
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
|
||||
const join = (arr, delimiter = '') => arr.join(delimiter);
|
||||
|
||||
const printTree = (nodes, indentLevel = 0) => {
|
||||
@ -39,8 +41,12 @@ describe('fixtures', () => {
|
||||
fixturePath = resolve(fixturePath, fixtureDir.replace('-with-cwd', ''));
|
||||
}
|
||||
|
||||
await sleep(1);
|
||||
|
||||
const output = await buildDirectory(fixtureDir);
|
||||
|
||||
await sleep(1);
|
||||
|
||||
const printedDir = printTree([dirTree(fixturePath)]);
|
||||
|
||||
expect(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user