Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

fix: set a name to exported fn #299

Merged
merged 5 commits into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 27 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -41,8 +41,8 @@
"webpack": "^4.0.0 || ^5.0.0"
},
"dependencies": {
"camelcase": "^6.2.0",
ramasilveyra marked this conversation as resolved.
Show resolved Hide resolved
"loader-utils": "^2.0.0",
"lodash.camelcase": "^4.3.0",
"schema-utils": "^3.0.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
@@ -1,5 +1,5 @@
import { stringifyRequest } from 'loader-utils';
import camelcase from 'lodash.camelcase';
import camelcase from 'camelcase';

function getDefaultFilename(filename) {
if (typeof filename === 'function') {
Expand Down Expand Up @@ -49,7 +49,7 @@ function workerGenerator(loaderContext, workerFilename, workerSource, options) {

const esModule =
typeof options.esModule !== 'undefined' ? options.esModule : true;
const fnName = `${camelcase(workerFilename)}Worker`;
const fnName = `${camelcase(workerFilename.replace(/\//g, ''))}Worker`;

if (options.inline) {
const InlineWorkerPath = stringifyRequest(
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/publicPath.test.js.snap
Expand Up @@ -5,14 +5,14 @@ exports[`"publicPath" option should work and respect "filename" and "chunkFilena
exports[`"publicPath" option should work and respect "filename" and "chunkFilename" option values: errors 2`] = `Array []`;

exports[`"publicPath" option should work and respect "filename" and "chunkFilename" option values: module 1`] = `
"export default function otherStaticJsWorkerBundleWorkerJsWorker() {
"export default function otherStaticjsworkerBundleWorkerJsWorker() {
return new Worker(__webpack_public_path__ + \\"other-static/js/worker.bundle.worker.js\\");
}
"
`;

exports[`"publicPath" option should work and respect "filename" and "chunkFilename" option values: module 2`] = `
"export default function otherStaticJsWorkerWorkerJsWorker() {
"export default function otherStaticjsworkerWorkerJsWorker() {
return new Worker(__webpack_public_path__ + \\"other-static/js/worker.worker.js\\");
}
"
Expand Down