Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 9f1ea59

Browse files
committed
Ensure that the webpack output filename ends with .js.
This ensures that the Webpack SourceMapDevToolPlugin can handle the file, even when it has been originally no javascript file (e.g. .ts or .feature).
1 parent ba9d44c commit 9f1ea59

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ const preprocessor = (options = {}) => {
7676
// we're provided a default output path that lives alongside Cypress's
7777
// app data files so we don't have to worry about where to put the bundled
7878
// file on disk
79-
const outputPath = file.outputPath
79+
const outputPath = path.extname(file.outputPath) === '.js'
80+
? file.outputPath
81+
: `${file.outputPath}.js`
8082

8183
// we need to set entry and output
8284
webpackOptions = Object.assign(webpackOptions, {

test/unit/index.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ describe('webpack preprocessor', function () {
132132
})
133133
})
134134

135+
it('adds .js extension to filename when the originating file had been no javascript file', function () {
136+
this.file.outputPath = 'output/output.ts'
137+
138+
return this.run().then(() => {
139+
expect(webpack.lastCall.args[0].output).to.eql({
140+
path: 'output',
141+
filename: 'output.ts.js',
142+
})
143+
})
144+
})
145+
135146
it('enables inline source maps', function () {
136147
return this.run().then(() => {
137148
expect(webpack.lastCall.args[0].devtool).to.equal('inline-source-map')
@@ -179,6 +190,15 @@ describe('webpack preprocessor', function () {
179190
})
180191
})
181192

193+
it('adds .js extension and resolves with that output path when the originating file had been no javascript file', function () {
194+
this.file.outputPath = 'output/output.ts'
195+
const expectedOutputPath = 'output/output.ts.js'
196+
197+
return this.run().then((outputPath) => {
198+
expect(outputPath).to.be.equal(expectedOutputPath)
199+
})
200+
})
201+
182202
it('emits "rerun" when shouldWatch is true and there is an update', function () {
183203
this.file.shouldWatch = true
184204
this.compilerApi.watch.yields(null, this.statsApi)

0 commit comments

Comments
 (0)