@modern-js/babel-compiler 1.1.3 → 1.1.4-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/js/modern/compiler.js +4 -0
- package/dist/js/node/compiler.js +4 -0
- package/dist/types/compiler.d.ts +1 -0
- package/package.json +4 -4
- package/src/compiler.ts +22 -3
- package/tests/compiler.test.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,7 @@ export const getDistFilePath = option => {
|
|
|
24
24
|
export const resolveSourceMap = option => {
|
|
25
25
|
const {
|
|
26
26
|
babelRes,
|
|
27
|
+
sourceFilePath,
|
|
27
28
|
distFilePath,
|
|
28
29
|
enableVirtualDist = false
|
|
29
30
|
} = option;
|
|
@@ -32,6 +33,7 @@ export const resolveSourceMap = option => {
|
|
|
32
33
|
|
|
33
34
|
if (babelRes.map) {
|
|
34
35
|
babelRes.map.file = path.basename(distFilePath);
|
|
36
|
+
babelRes.map.sources = [path.relative(path.dirname(distFilePath), sourceFilePath)];
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
const sourceMapVirtualDist = {
|
|
@@ -85,12 +87,14 @@ export const compiler = option => {
|
|
|
85
87
|
if (virtualDist) {
|
|
86
88
|
virtualDist = _objectSpread(_objectSpread({}, virtualDist), resolveSourceMap({
|
|
87
89
|
babelRes,
|
|
90
|
+
sourceFilePath: filepath,
|
|
88
91
|
distFilePath,
|
|
89
92
|
enableVirtualDist
|
|
90
93
|
}));
|
|
91
94
|
} else {
|
|
92
95
|
resolveSourceMap({
|
|
93
96
|
babelRes,
|
|
97
|
+
sourceFilePath: filepath,
|
|
94
98
|
distFilePath,
|
|
95
99
|
enableVirtualDist
|
|
96
100
|
});
|
package/dist/js/node/compiler.js
CHANGED
|
@@ -47,6 +47,7 @@ exports.getDistFilePath = getDistFilePath;
|
|
|
47
47
|
const resolveSourceMap = option => {
|
|
48
48
|
const {
|
|
49
49
|
babelRes,
|
|
50
|
+
sourceFilePath,
|
|
50
51
|
distFilePath,
|
|
51
52
|
enableVirtualDist = false
|
|
52
53
|
} = option;
|
|
@@ -55,6 +56,7 @@ const resolveSourceMap = option => {
|
|
|
55
56
|
|
|
56
57
|
if (babelRes.map) {
|
|
57
58
|
babelRes.map.file = path.basename(distFilePath);
|
|
59
|
+
babelRes.map.sources = [path.relative(path.dirname(distFilePath), sourceFilePath)];
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
const sourceMapVirtualDist = {
|
|
@@ -113,12 +115,14 @@ const compiler = option => {
|
|
|
113
115
|
if (virtualDist) {
|
|
114
116
|
virtualDist = _objectSpread(_objectSpread({}, virtualDist), resolveSourceMap({
|
|
115
117
|
babelRes,
|
|
118
|
+
sourceFilePath: filepath,
|
|
116
119
|
distFilePath,
|
|
117
120
|
enableVirtualDist
|
|
118
121
|
}));
|
|
119
122
|
} else {
|
|
120
123
|
resolveSourceMap({
|
|
121
124
|
babelRes,
|
|
125
|
+
sourceFilePath: filepath,
|
|
122
126
|
distFilePath,
|
|
123
127
|
enableVirtualDist
|
|
124
128
|
});
|
package/dist/types/compiler.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1.
|
|
14
|
+
"version": "1.1.4-rc.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/core": "^7.15.0",
|
|
31
31
|
"@babel/runtime": "^7",
|
|
32
|
-
"@modern-js/utils": "^1.1.
|
|
32
|
+
"@modern-js/utils": "^1.1.6-rc.0",
|
|
33
33
|
"chokidar": "^3.5.2",
|
|
34
34
|
"glob": "^7.1.6"
|
|
35
35
|
},
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@types/node": "^14",
|
|
43
43
|
"jest-jasmine2": "^27.2.2",
|
|
44
44
|
"typescript": "^4",
|
|
45
|
-
"@modern-js/plugin-testing": "^1.
|
|
46
|
-
"@modern-js/module-tools": "^1.1.
|
|
45
|
+
"@modern-js/plugin-testing": "^1.2.2",
|
|
46
|
+
"@modern-js/module-tools": "^1.1.4"
|
|
47
47
|
},
|
|
48
48
|
"sideEffects": false,
|
|
49
49
|
"modernConfig": {
|
package/src/compiler.ts
CHANGED
|
@@ -38,15 +38,24 @@ export const getDistFilePath = (option: {
|
|
|
38
38
|
|
|
39
39
|
export const resolveSourceMap = (option: {
|
|
40
40
|
babelRes: babel.BabelFileResult;
|
|
41
|
+
sourceFilePath: string;
|
|
41
42
|
distFilePath: string;
|
|
42
43
|
enableVirtualDist?: boolean;
|
|
43
44
|
}) => {
|
|
44
|
-
const {
|
|
45
|
+
const {
|
|
46
|
+
babelRes,
|
|
47
|
+
sourceFilePath,
|
|
48
|
+
distFilePath,
|
|
49
|
+
enableVirtualDist = false,
|
|
50
|
+
} = option;
|
|
45
51
|
const mapLoc = `${distFilePath}.map`;
|
|
46
52
|
babelRes.code = utils.addSourceMappingUrl(babelRes.code as string, mapLoc);
|
|
47
53
|
|
|
48
54
|
if (babelRes.map) {
|
|
49
55
|
babelRes.map.file = path.basename(distFilePath);
|
|
56
|
+
babelRes.map.sources = [
|
|
57
|
+
path.relative(path.dirname(distFilePath), sourceFilePath),
|
|
58
|
+
];
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
const sourceMapVirtualDist = {
|
|
@@ -106,10 +115,20 @@ export const compiler = (option: ISingleFileCompilerOption) => {
|
|
|
106
115
|
if (virtualDist) {
|
|
107
116
|
virtualDist = {
|
|
108
117
|
...virtualDist,
|
|
109
|
-
...resolveSourceMap({
|
|
118
|
+
...resolveSourceMap({
|
|
119
|
+
babelRes,
|
|
120
|
+
sourceFilePath: filepath,
|
|
121
|
+
distFilePath,
|
|
122
|
+
enableVirtualDist,
|
|
123
|
+
}),
|
|
110
124
|
};
|
|
111
125
|
} else {
|
|
112
|
-
resolveSourceMap({
|
|
126
|
+
resolveSourceMap({
|
|
127
|
+
babelRes,
|
|
128
|
+
sourceFilePath: filepath,
|
|
129
|
+
distFilePath,
|
|
130
|
+
enableVirtualDist,
|
|
131
|
+
});
|
|
113
132
|
}
|
|
114
133
|
}
|
|
115
134
|
|
package/tests/compiler.test.ts
CHANGED
|
@@ -49,6 +49,7 @@ describe('compiler', () => {
|
|
|
49
49
|
const distFilePath = path.join(projectDir, 'dist/far.js');
|
|
50
50
|
const sourcemap_1 = resolveSourceMap({
|
|
51
51
|
babelRes: babelRes as babel.BabelFileResult,
|
|
52
|
+
sourceFilePath: path.join(projectDir, 'src/index.js'),
|
|
52
53
|
distFilePath,
|
|
53
54
|
enableVirtualDist: true,
|
|
54
55
|
});
|
|
@@ -59,6 +60,7 @@ describe('compiler', () => {
|
|
|
59
60
|
|
|
60
61
|
const sourcemap_2 = resolveSourceMap({
|
|
61
62
|
babelRes: babelRes as babel.BabelFileResult,
|
|
63
|
+
sourceFilePath: path.join(projectDir, 'src/index.js'),
|
|
62
64
|
distFilePath,
|
|
63
65
|
});
|
|
64
66
|
expect(fs.readFileSync(sourcemap_2.sourceMapPath, 'utf-8')).toBe(
|