Skip to content

Commit 3a578d4

Browse files
committed
build: fix cjs builds
something we didn't realize when moving to named imports is that rollup doesn't consider those imports modules to be preserved, so we can't rely on the tests to find all the required files to build anymore
1 parent 210588c commit 3a578d4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "rollup --config rollup.config.js",
99
"prepublishOnly": "npm run build",
1010
"lint": "standard",
11-
"test:cjs": "npm run build && du -a dist && mocha dist/test/test-*.cjs",
11+
"test:cjs": "rm -rf dist && npm run build && mocha dist/test/test-*.cjs",
1212
"test:node": "hundreds mocha test/test-*.js",
1313
"test:browser": "polendina --webpack-config polendina.webpack.config.cjs --cleanup test/test-*.js",
1414
"test": "npm run lint && npm run test:node && npm run test:browser && npm run test:cjs",

rollup.config.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { join } from 'path'
33

44
const dir = 'dist'
55
const preserveModules = true
6-
const output = { dir, preserveModules, format: 'cjs', entryFileNames: '[name].cjs' }
7-
const testdir = join(__dirname, 'test')
8-
const filter = name => name.startsWith('test-')
9-
const createConfig = f => ({ input: join('test', f), output })
10-
11-
const configs = readdirSync(testdir).filter(filter).map(createConfig)
12-
6+
const configs = []
7+
for (const subdir of ['test', 'bases', 'hashes', 'codecs', '.']) {
8+
const output = { dir: join(dir, subdir), preserveModules, format: 'cjs', entryFileNames: '[name].cjs' }
9+
const testdir = join(__dirname, subdir)
10+
const filter = name => name.endsWith('.js')
11+
const createConfig = f => ({ input: join(subdir, f), output })
12+
readdirSync(testdir).filter(filter).map(createConfig).forEach(c => configs.push(c))
13+
}
1314
console.log(configs)
1415

1516
export default configs

0 commit comments

Comments
 (0)