diff --git a/src/utils.js b/src/utils.js index 3797bb7..8db6af8 100644 --- a/src/utils.js +++ b/src/utils.js @@ -87,7 +87,7 @@ ${ } // Matches only the last occurrence of sourceMappingURL -const innerRegex = /\s*[#@]\s*sourceMappingURL\s*=\s*([^\s'"]*)\s*/; +const innerRegex = /\s*[#@]\s*sourceMappingURL\s*=\s*(.*?(?=[\s'"]|\\n|$)(?:\\n)?)\s*/; /* eslint-disable prefer-template */ const sourceMappingURLRegex = RegExp( diff --git a/test/__snapshots__/inline-option.test.js.snap b/test/__snapshots__/inline-option.test.js.snap index 9af5142..8414722 100644 --- a/test/__snapshots__/inline-option.test.js.snap +++ b/test/__snapshots__/inline-option.test.js.snap @@ -55,6 +55,12 @@ exports[`"inline" option should work with "no-fallback" value and "esModule" wit exports[`"inline" option should work with "no-fallback" value and "esModule" with "true" value: warnings 1`] = `Array []`; +exports[`"inline" option should work with "no-fallback" value and the "devtool" option ("eval-source-map" value): errors 1`] = `Array []`; + +exports[`"inline" option should work with "no-fallback" value and the "devtool" option ("eval-source-map" value): result 1`] = `"{\\"postMessage\\":true,\\"onmessage\\":true}"`; + +exports[`"inline" option should work with "no-fallback" value and the "devtool" option ("eval-source-map" value): warnings 1`] = `Array []`; + exports[`"inline" option should work with "no-fallback" value and the "devtool" option ("source-map" value): errors 1`] = `Array []`; exports[`"inline" option should work with "no-fallback" value and the "devtool" option ("source-map" value): errors 2`] = `Array []`; diff --git a/test/inline-option.test.js b/test/inline-option.test.js index 763303a..3b3b436 100644 --- a/test/inline-option.test.js +++ b/test/inline-option.test.js @@ -62,6 +62,42 @@ describe('"inline" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); + it('should work with "no-fallback" value and the "devtool" option ("eval-source-map" value)', async () => { + const compiler = getCompiler( + './basic/entry.js', + { inline: 'no-fallback' }, + { devtool: 'eval-source-map' } + ); + const stats = await compile(compiler); + const result = await getResultFromBrowser(stats); + const moduleSource = getModuleSource('./basic/worker.js', stats); + const sourceUrlInternalIndex = moduleSource.indexOf( + 'sourceURL=webpack-internal:///./basic/worker.js' + ); + + expect(moduleSource.indexOf('inline.js') > 0).toBe(true); + expect( + moduleSource.indexOf('__webpack_public_path__ + "test.worker.js"') === -1 + ).toBe(true); + expect( + moduleSource.indexOf( + 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + ) === -1 + ).toBe(true); + expect(sourceUrlInternalIndex >= 0).toBe(true); + expect( + moduleSource.lastIndexOf('//', sourceUrlInternalIndex) > + moduleSource.lastIndexOf('\\n', sourceUrlInternalIndex) || + moduleSource.lastIndexOf('/*', sourceUrlInternalIndex) > + moduleSource.lastIndexOf('*/', sourceUrlInternalIndex) + ).toBe(true); + expect(stats.compilation.assets['test.worker.js']).toBeUndefined(); + expect(stats.compilation.assets['test.worker.js.map']).toBeUndefined(); + expect(result).toMatchSnapshot('result'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + it('should work with "no-fallback" value and the "devtool" option ("source-map" value)', async () => { const compiler = getCompiler( './basic/entry.js',