question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

workbox-webpack-plugin build error with TypeScript and eval-cheap-source-map

See original GitHub issue

Welcome! Please use this template for reporting bugs or requesting features. For questions about using Workbox, the best place to ask is Stack Overflow, tagged with [workbox]: https://stackoverflow.com/questions/ask?tags=workbox

Library Affected: workbox-webpack-plugin

Browser & Platform: all browsers

Issue or Feature Request Description: When using workbox-webpack-plugin with TypeScript and eval-cheap-source-map, the following error is generated for the service worker and execution halts:

Uncaught SyntaxError: missing ) after argument list, line 25 of sw.js

This doesn’t happen with inline-source-map. I’ve been using this but it’s very slow.

Here is the webpack config bits:

module.exports = {
	devtool: devMode ?
		"eval-cheap-source-map" :
		false,
...
	module: {
		rules: [
			{
				test: /\.(js|ts)$/,
				use: {
					loader: "ts-loader",
					options: {
						happyPackMode: true,
					},
				},
			},
...
	plugins: [
		new InjectManifest({
			swDest: "sw.js",
			swSrc: "./src/sw.ts",
		}),

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jeffposnickcommented, Jun 11, 2021

Hello @alexburlton-sonocent—all of the Workbox libraries are released concurrently (using lerna) and have matching version numbers.

The fix for this issue was merged into the v6 branch and will go live with the planned v6.2.0 release of all of the Workbox libraries (including workbox-webpack-plugin), which is unfortunately still blocked on a few more changes we plan on making.

We don’t anticipate backporting this sort of change to the v5.x releases.

0reactions
TravelFiendcommented, Nov 22, 2022

This issue is still occurring in my React 18 app on the latest workbox version (6.5.4). Here’s my webpack config file:

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const DotEnv = require('dotenv-webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const { InjectManifest } = require('workbox-webpack-plugin');


const currentTask = process.env.npm_lifecycle_event;

const config = {
  context: __dirname,
  entry: './src/index.js',
  output: {
    filename: 'bundle.[fullhash].js',
    path: path.resolve(__dirname, 'dist'),
    clean: true
  },
  plugins: [
    new HtmlWebpackPlugin({ template: './src/index.html'}),
    new DotEnv({ systemvars: true }),
    new CopyPlugin({ patterns: [{ from: 'public' }] })
  ],
  devtool: 'eval-cheap-source-map',
  devServer: {
    port: 7890,
    static: path.resolve(__dirname, 'dist'),
    hot: true,
    open: true
  },
  mode: 'development',
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            cacheDirectory: true
          }
        }
      },
      {
        test: /\.(sc|c)ss$/i,
        use: [
          'style-loader',
          'css-loader',
          'sass-loader'
        ]
      },
      {
        test: /\.(jpeg|jpg|png|svg|pdf)$/,
        use: {
          loader: 'file-loader?name=.public/assets/images/[name].[ext]'
        },
      }
    ]
  }
};

if (currentTask === 'build'){
  config.mode = 'production';
  config.plugins.push(
    new MiniCssExtractPlugin({ filename: 'main.[fullhash].css' }),
    new InjectManifest({
      swSrc: './src/serviceWorker/ServiceWorker.js',
      swDest: 'sw.js'
    })
  );
  config.module.rules[1].use[0] = MiniCssExtractPlugin.loader;
}

module.exports = config;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatsby 4 upgrade - typescript errors? Not using typescript
I'm getting these build errors and I don't know where to start! I'm not using gatsby-plugin-typescript. Thanks!
Read more >
workbox-build 6.2.0-alpha.0 on Node.js NPM - NewReleases.io
The workbox-build module has been rewritten in TypeScript, following the earlier migration of the workbox-cli module. ( workbox-webpack-plugin has not yet ...
Read more >
workbox-build: Versions - Openbase
We upgraded to TypeScript 4.4.3. · You can check the number of requests in the sync queue with the new method size() ....
Read more >
Create a service worker with Workbox, Webpack and TypeScript
__WB_MANIFEST) . Anyway there's a problem: I want to cache some additional files during the installation process to be used to manage errors...
Read more >
Troubleshooting Issues with the TypeScript SDK
Worker errors and logs are reflected in the terminal. If something isn't behaving the way you expect, make sure to check both locations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found