mirror of
https://github.com/developit/microbundle.git
synced 2026-01-25 14:06:50 +00:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
952aedec14
@ -117,6 +117,7 @@ Here's what's coming up for Microbundle:
|
||||
- [brazilian-utils](https://github.com/brazilian-utils/brazilian-utils) Utils library for specific Brazilian businesses.
|
||||
- [react-hooks-lib](https://github.com/beizhedenglong/react-hooks-lib) A set of reusable react hooks.
|
||||
- [mdx-deck-live-code](https://github.com/JReinhold/mdx-deck-live-code) A library for [mdx-deck](https://github.com/jxnblk/mdx-deck) to do live React and JS coding directly in slides.
|
||||
- [react-router-ext](https://github.com/ri7nz/react-router-ext) An Extended [react-router-dom](https://github.com/ReactTraining/react-router/tree/master/packages/react-router-dom) with simple usage.
|
||||
|
||||
## 🥂 License
|
||||
|
||||
|
||||
@ -418,6 +418,9 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
}
|
||||
return externalTest(id);
|
||||
},
|
||||
treeshake: {
|
||||
propertyReadSideEffects: false,
|
||||
},
|
||||
plugins: []
|
||||
.concat(
|
||||
postcss({
|
||||
@ -592,9 +595,6 @@ function createConfig(options, entry, format, writeMeta) {
|
||||
freeze: false,
|
||||
esModule: false,
|
||||
sourcemap: options.sourcemap,
|
||||
treeshake: {
|
||||
propertyReadSideEffects: false,
|
||||
},
|
||||
format,
|
||||
name: options.name,
|
||||
file: resolve(
|
||||
|
||||
@ -14,26 +14,34 @@ const rimraf = promisify(_rimraf);
|
||||
const FIXTURES_DIR = `${__dirname}/fixtures`;
|
||||
const DEFAULT_SCRIPT = 'microbundle';
|
||||
|
||||
const times = (n, fn) => Array.from({ length: n }).map(i => fn(i));
|
||||
const join = (arr, delimiter = '') => arr.join(delimiter);
|
||||
const constant = konst => () => konst;
|
||||
|
||||
const printTree = (nodes, indentLevel = 0) => {
|
||||
const indent = join(times(indentLevel, constant(' ')));
|
||||
const indent = ' '.repeat(indentLevel);
|
||||
return join(
|
||||
nodes
|
||||
.filter(node => node.name[0] !== '.')
|
||||
.map(
|
||||
node =>
|
||||
`${indent}${node.name}\n${
|
||||
node.type === 'directory'
|
||||
? printTree(node.children, indentLevel + 1)
|
||||
: ''
|
||||
}`,
|
||||
),
|
||||
.map(node => {
|
||||
const isDir = node.type === 'directory';
|
||||
return `${indent}${node.name}\n${
|
||||
isDir ? printTree(node.children, indentLevel + 1) : ''
|
||||
}`;
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const getBuildScript = async (fixturePath, defaultScript) => {
|
||||
let pkg = {};
|
||||
try {
|
||||
pkg = JSON.parse(
|
||||
await readFile(resolve(fixturePath, 'package.json'), 'utf8'),
|
||||
);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ENOENT') throw err;
|
||||
}
|
||||
return (pkg && pkg.scripts && pkg.scripts.build) || defaultScript;
|
||||
};
|
||||
|
||||
const parseScript = (() => {
|
||||
let parsed;
|
||||
const prog = createProg(_parsed => (parsed = _parsed));
|
||||
@ -65,13 +73,7 @@ describe('fixtures', () => {
|
||||
await rimraf(resolve(`${fixturePath}/.rts2_cache_es`));
|
||||
await rimraf(resolve(`${fixturePath}/.rts2_cache_umd`));
|
||||
|
||||
let script;
|
||||
try {
|
||||
({ scripts: { build: script } = {} } = JSON.parse(
|
||||
await readFile(resolve(fixturePath, 'package.json'), 'utf8'),
|
||||
));
|
||||
} catch (err) {}
|
||||
script = script || DEFAULT_SCRIPT;
|
||||
const script = await getBuildScript(fixturePath, DEFAULT_SCRIPT);
|
||||
|
||||
const prevDir = process.cwd();
|
||||
process.chdir(resolve(fixturePath));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user