feat(webpack): place hidden sourceMaps in platforms folder (#10352)

This commit is contained in:
Igor Randjelovic
2023-08-03 22:40:42 +02:00
committed by GitHub
parent 0efb84ff44
commit 3325b3ec0b
3 changed files with 25 additions and 2 deletions

View File

@ -648,3 +648,5 @@ exports[`base configuration support env.watchNodeModules 1`] = `
"managedPaths": [], "managedPaths": [],
} }
`; `;
exports[`base configuration supports env.sourceMap=hidden-source-map 1`] = `"../../../ios-sourceMaps/[file].map[query]"`;

View File

@ -210,4 +210,15 @@ describe('base configuration', () => {
expect(config.get('profile')).toBe(true); expect(config.get('profile')).toBe(true);
}); });
it('supports env.sourceMap=hidden-source-map', () => {
init({
ios: true,
sourceMap: 'hidden-source-map',
});
const config = base(new Config());
expect(config.output.get('sourceMapFilename')).toMatchSnapshot();
expect(config.get('devtool')).toBe('hidden-source-map');
});
}); });

View File

@ -1,4 +1,4 @@
import { extname, resolve } from 'path'; import { extname, relative, resolve } from 'path';
import { import {
ContextExclusionPlugin, ContextExclusionPlugin,
DefinePlugin, DefinePlugin,
@ -32,6 +32,7 @@ import {
export default function (config: Config, env: IWebpackEnv = _env): Config { export default function (config: Config, env: IWebpackEnv = _env): Config {
const entryPath = getEntryPath(); const entryPath = getEntryPath();
const platform = getPlatformName(); const platform = getPlatformName();
const outputPath = getAbsoluteDistPath();
const mode = env.production ? 'production' : 'development'; const mode = env.production ? 'production' : 'development';
// set mode // set mode
@ -80,6 +81,15 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
config.devtool(getSourceMapType(env.sourceMap)); config.devtool(getSourceMapType(env.sourceMap));
// when using hidden-source-map, output source maps to the `platforms/{platformName}-sourceMaps` folder
if (env.sourceMap === 'hidden-source-map') {
const sourceMapAbsolutePath = getProjectFilePath(
`./platforms/${platform}-sourceMaps/[file].map[query]`
);
const sourceMapRelativePath = relative(outputPath, sourceMapAbsolutePath);
config.output.sourceMapFilename(sourceMapRelativePath);
}
// todo: figure out easiest way to make "node" target work in ns // todo: figure out easiest way to make "node" target work in ns
// rather than the custom ns target implementation that's hard to maintain // rather than the custom ns target implementation that's hard to maintain
// appears to be working - but we still have to deal with HMR // 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 {
}); });
config.output config.output
.path(getAbsoluteDistPath()) .path(outputPath)
.pathinfo(false) .pathinfo(false)
.publicPath('') .publicPath('')
.libraryTarget('commonjs') .libraryTarget('commonjs')