Skip to content

Commit

Permalink
Configures build to point to the built service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed May 7, 2020
1 parent 241572d commit ec45574
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
command: yarn build

- run:
name: Distributed Service Worker preview
command: cat lib/mockServiceWorker.js
name: Preview Service Worker build
command: cat lib/esm/mockServiceWorker.js

- run:
name: Unit tests
Expand Down
2 changes: 1 addition & 1 deletion config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const SERVICE_WORKER_SOURCE_PATH = path.resolve(
const SERVICE_WORKER_BUILD_PATH = path.resolve(
__dirname,
'../',
path.dirname(packageJson.main),
path.dirname(packageJson.module),
path.basename(SERVICE_WORKER_SOURCE_PATH),
)

Expand Down
2 changes: 1 addition & 1 deletion rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const buildEsm = {
output: [
{
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
chunkFileNames: '[name]-deps.js',
dir: path.dirname(packageJson.module),
format: 'esm',
},
Expand Down
2 changes: 1 addition & 1 deletion src/rest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import rest from './rest'
import { rest } from './rest'

test('Exports all REST API methods', () => {
expect(rest).not.toBeUndefined()
Expand Down
2 changes: 1 addition & 1 deletion src/setupWorker/setupWorker.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setupWorker } from './setupWorker'
import rest, { restContext } from '../handlers/rest'
import { rest, restContext } from '../rest'
import { MockedRequest, ResponseResolver } from '../handlers/requestHandler'

test('Generates schema based on provided handlers', () => {
Expand Down
3 changes: 2 additions & 1 deletion test/support/spawnServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as chalk from 'chalk'
import * as webpack from 'webpack'
import * as WebpackDevServer from 'webpack-dev-server'
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
import { SERVICE_WORKER_BUILD_PATH } from '../../config/constants'
import * as packageJson from '../../package.json'

interface Payload {
Expand Down Expand Up @@ -86,7 +87,7 @@ Resolved "msw" module to:
},
after(app, server, compiler) {
app.get('/mockServiceWorker.js', (req, res) => {
res.sendFile(path.resolve(__dirname, '../../lib/mockServiceWorker.js'))
res.sendFile(SERVICE_WORKER_BUILD_PATH)
})

if (options?.withRoutes) {
Expand Down

0 comments on commit ec45574

Please sign in to comment.