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

Commit a6baf1f

Browse files
fix: Ensure that the webpack output filename ends with .js. (#73)
This ensures that the Webpack SourceMapDevToolPlugin can handle the file, even when it has been originally no javascript file (e.g. .ts or .feature). Co-authored-by: Chris Breiding <[email protected]>
1 parent dd2575b commit a6baf1f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-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: 19 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,14 @@ 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+
196+
return this.run().then((outputPath) => {
197+
expect(outputPath).to.be.equal('output/output.ts.js')
198+
})
199+
})
200+
182201
it('emits "rerun" when shouldWatch is true and there is an update', function () {
183202
this.file.shouldWatch = true
184203
this.compilerApi.watch.yields(null, this.statsApi)

0 commit comments

Comments
 (0)