8000 feat(webpack): place hidden sourceMaps in platforms folder (#10352) · NativeScript/NativeScript@3325b3e · GitHub
[go: up one dir, main page]

Skip to content

Commit 3325b3e

Browse files
authored
feat(webpack): place hidden sourceMaps in platforms folder (#10352)
1 parent 0efb84f commit 3325b3e

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

packages/webpack5/__tests__/configuration/__snapshots__/base.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,5 @@ exports[`base configuration support env.watchNodeModules 1`] = `
648648
"managedPaths": [],
649649
}
650650
`;
651+
652+
exports[`base configuration supports env.sourceMap=hidden-source-map 1`] = `"../../../ios-sourceMaps/[file].map[query]"`;

packages/webpack5/__tests__/configuration/base.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,15 @@ describe('base configuration', () => {
210210

211211
expect(config.get('profile')).toBe(true);
212212
});
213+
214+
it('supports env.sourceMap=hidden-source-map', () => {
215+
init({
216+
ios: true,
217+
sourceMap: 'hidden-source-map',
218+
});
219+
const config = base(new Config());
220+
221+
expect(config.output.get('sourceMapFilename')).toMatchSnapshot();
222+
expect(config.get('devtool')).toBe('hidden-source-map');
223+
});
213224
});

packages/webpack5/src/configuration/base.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { extname, resolve } from 'path';
1+
import { extname, relative, resolve } from 'path';
22
import {
33
ContextExclusionPlugin,
44
DefinePlugin,
@@ -32,6 +32,7 @@ import {
3232
export default function (config: Config, env: IWebpackEnv = _env): Config {
3333
const entryPath = getEntryPath();
3434
const platform = getPlatformName();
35+
const outputPath = getAbsoluteDistPath();
3536
const mode = env.production ? 'production' : 'development';
3637

3738
// set mode
@@ -80,6 +81,15 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
8081

8182
config.devtool(getSourceMapType(env.sourceMap));
8283

84+
// when using hidden-source-map, output source maps to the `platforms/{platformName}-sourceMaps` folder
85+
if (env.sourceMap === 'hidden-source-map') {
86+
const sourceMapAbsolutePath = getProjectFilePath(
87+
`./platforms/${platform}-sourceMaps/[file].map[query]`
88+
);
89+
const sourceMapRelativePath = relative(outputPath, sourceMapAbsolutePath);
90+
config.output.sourceMapFilename(sourceMapRelativePath);
91+
}
92+
8393
// todo: figure out easiest way to make "node" target work in ns
8494
// rather than the custom ns target implementation that's hard to maintain
8595
// appears to be working - but we still have to deal with HMR
@@ -110,7 +120,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
110120
});
111121

112122
config.output
113-
.path(getAbsoluteDistPath())
123+
.path(outputPath)
114124
.pathinfo(false)
115125
.publicPath('')
116126
.libraryTarget('commonjs')

0 commit comments

Comments
 (0)
0