Skip to content

Commit 6f64262

Browse files
test: source map
1 parent d12cd13 commit 6f64262

File tree

7 files changed

+1947
-2381
lines changed

7 files changed

+1947
-2381
lines changed

package-lock.json

+1,848-2,309
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"release": "standard-version",
2727
"release:ci": "conventional-github-releaser -p angular",
2828
"release:validate": "commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)",
29-
"security": "nsp check",
29+
"security": "npm audit",
3030
"test": "jest",
3131
"test:watch": "jest --watch",
3232
"test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
@@ -69,7 +69,6 @@
6969
"jest": "^22.2.2",
7070
"lint-staged": "^6.1.0",
7171
"memory-fs": "^0.4.1",
72-
"nsp": "^3.1.0",
7372
"pre-commit": "^1.2.2",
7473
"prettier": "^1.11.1",
7574
"standard-version": "^4.3.0",

test/TestCases.test.js

+60-70
Original file line numberDiff line numberDiff line change
@@ -9,81 +9,71 @@ describe('TestCases', () => {
99
for (const directory of fs.readdirSync(casesDirectory)) {
1010
if (!/^(\.|_)/.test(directory)) {
1111
// eslint-disable-next-line no-loop-func
12-
it(
13-
`${directory} should compile to the expected result`,
14-
(done) => {
15-
const directoryForCase = path.resolve(casesDirectory, directory);
16-
const outputDirectoryForCase = path.resolve(
17-
outputDirectory,
18-
directory
12+
it(`${directory} should compile to the expected result`, (done) => {
13+
const directoryForCase = path.resolve(casesDirectory, directory);
14+
const outputDirectoryForCase = path.resolve(outputDirectory, directory);
15+
// eslint-disable-next-line import/no-dynamic-require, global-require
16+
const webpackConfig = require(path.resolve(
17+
directoryForCase,
18+
'webpack.config.js'
19+
));
20+
for (const config of [].concat(webpackConfig)) {
21+
Object.assign(
22+
config,
23+
{
24+
mode: 'none',
25+
context: directoryForCase,
26+
output: Object.assign(
27+
{
28+
path: outputDirectoryForCase,
29+
},
30+
config.output
31+
),
32+
},
33+
config
1934
);
20-
// eslint-disable-next-line import/no-dynamic-require, global-require
21-
const webpackConfig = require(path.resolve(
22-
directoryForCase,
23-
'webpack.config.js'
24-
));
25-
for (const config of [].concat(webpackConfig)) {
26-
Object.assign(
27-
config,
28-
{
29-
mode: 'none',
30-
context: directoryForCase,
31-
output: Object.assign(
32-
{
33-
path: outputDirectoryForCase,
34-
},
35-
config.output
36-
),
37-
},
38-
config
35+
}
36+
webpack(webpackConfig, (err, stats) => {
37+
if (err) {
38+
done(err);
39+
return;
40+
}
41+
done();
42+
// eslint-disable-next-line no-console
43+
console.log(
44+
stats.toString({
45+
context: path.resolve(__dirname, '..'),
46+
chunks: true,
47+
chunkModules: true,
48+
modules: false,
49+
})
50+
);
51+
if (stats.hasErrors()) {
52+
done(
53+
new Error(
54+
stats.toString({
55+
context: path.resolve(__dirname, '..'),
56+
errorDetails: true,
57+
})
58+
)
3959
);
60+
return;
4061
}
41-
webpack(webpackConfig, (err, stats) => {
42-
if (err) {
43-
done(err);
44-
return;
45-
}
46-
done();
47-
// eslint-disable-next-line no-console
48-
console.log(
49-
stats.toString({
50-
context: path.resolve(__dirname, '..'),
51-
chunks: true,
52-
chunkModules: true,
53-
modules: false,
54-
})
62+
const expectedDirectory = path.resolve(directoryForCase, 'expected');
63+
for (const file of fs.readdirSync(expectedDirectory)) {
64+
const content = fs.readFileSync(
65+
path.resolve(expectedDirectory, file),
66+
'utf-8'
5567
);
56-
if (stats.hasErrors()) {
57-
done(
58-
new Error(
59-
stats.toString({
60-
context: path.resolve(__dirname, '..'),
61-
errorDetails: true,
62-
})
63-
)
64-
);
65-
return;
66-
}
67-
const expectedDirectory = path.resolve(
68-
directoryForCase,
69-
'expected'
68+
const actualContent = fs.readFileSync(
69+
path.resolve(outputDirectoryForCase, file),
70+
'utf-8'
7071
);
71-
for (const file of fs.readdirSync(expectedDirectory)) {
72-
const content = fs.readFileSync(
73-
path.resolve(expectedDirectory, file),
74-
'utf-8'
75-
);
76-
const actualContent = fs.readFileSync(
77-
path.resolve(outputDirectoryForCase, file),
78-
'utf-8'
79-
);
80-
expect(actualContent).toEqual(content);
81-
}
82-
done();
83-
});
84-
},
85-
10000
86-
);
72+
expect(actualContent).toEqual(content);
73+
}
74+
done();
75+
});
76+
}, 10000);
8777
}
8878
}
8979
});

test/cases/source-map/expected/main.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cases/source-map/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './style.css';

test/cases/source-map/style.css

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body { background: red; }
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const Self = require('../../../');
2+
3+
module.exports = {
4+
entry: './index.js',
5+
devtool: "source-map",
6+
module: {
7+
rules: [
8+
{
9+
test: /\.css$/,
10+
use: [
11+
{
12+
loader: Self.loader,
13+
options: {
14+
sourceMap: true
15+
}
16+
},
17+
{
18+
loader: 'css-loader',
19+
options: {
20+
sourceMap: true
21+
}
22+
}
23+
],
24+
},
25+
],
26+
},
27+
plugins: [
28+
new Self({
29+
filename: '[name].css',
30+
}),
31+
],
32+
};

0 commit comments

Comments
 (0)