Skip to content

Commit 1f52a1f

Browse files
committed
chore: infra for units
1 parent 5d423df commit 1f52a1f

4 files changed

Lines changed: 52 additions & 3 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import path from 'path'
2+
import webpack from 'webpack'
3+
import { createFsFromVolume, Volume } from 'memfs'
4+
5+
export function compiler(fixture: any, options: any = {}) {
6+
const $compiler = webpack({
7+
context: __dirname,
8+
entry: `./${fixture}`,
9+
output: {
10+
path: path.resolve(__dirname),
11+
filename: 'bundle.js',
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.txt$/,
17+
use: {
18+
loader: path.resolve(__dirname, '../src/loader.js'),
19+
options,
20+
},
21+
},
22+
],
23+
},
24+
plugins: options.plugins,
25+
})
26+
27+
$compiler.outputFileSystem = createFsFromVolume(new Volume())
28+
$compiler.outputFileSystem.join = path.join.bind(path)
29+
30+
return new Promise((resolve, reject) => {
31+
$compiler.run((err, stats) => {
32+
if (err) reject(err)
33+
if (stats.hasErrors()) reject(new Error(stats.toJson().errors))
34+
35+
resolve(stats)
36+
})
37+
})
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import FeatureFlagsWebpackPlugin from '../src/index'
2+
import { compiler } from './__internal__/compiler'
3+
4+
test('yyy', async () => {
5+
const plugin = new FeatureFlagsWebpackPlugin()
6+
await compiler('', { plugins: [plugin] })
7+
8+
expect(1).toBe(1)
9+
})

packages/feature-flags-webpack-plugin/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/feature-flags-webpack-plugin/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
"scripts": {
1919
"build": "tsc",
2020
"cleanup": "rm -rf lib",
21+
"dev": "tsc -w",
2122
"prepublishOnly": "npm run cleanup && npm run build",
2223
"unit": "../../node_modules/.bin/jest --config ../../.config/jest/jest.config.js"
2324
},
2425
"devDependencies": {
25-
"@types/webpack": "4.41.25",
26-
"typescript": "4.1.3"
26+
"memfs": "3.2.0",
27+
"typescript": "4.1.3",
28+
"webpack": "5.11.0"
2729
}
2830
}

0 commit comments

Comments
 (0)