Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 [RUM-232] fix worker/string package #2331

Merged
merged 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/worker/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
*
!/bundle/worker.js
!/string/**/*
!/cjs/**/*
!/esm/**/*
!/src/**/*
/src/**/*.spec.ts
/src/**/*.specHelper.ts
12 changes: 10 additions & 2 deletions packages/worker/scripts/build-worker-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ const fs = require('fs')

const bundlePath = path.resolve(__dirname, '../bundle')
const workerBundlePath = path.join(bundlePath, 'worker.js')
const workerStringPath = path.join(bundlePath, 'workerString.ts')
const workerBundleContent = fs.readFileSync(workerBundlePath, { encoding: 'utf-8' })

fs.writeFileSync(workerStringPath, `export const workerString = ${JSON.stringify(workerBundleContent)}`)
const workerString = `${JSON.stringify(workerBundleContent)}\n`
writeOutput('cjs', `exports.workerString = ${workerString}`)
writeOutput('esm', `export const workerString = ${workerString}`)

function writeOutput(moduleType, content) {
const outputPath = path.resolve(__dirname, path.join('..', moduleType, 'entries'))
fs.mkdirSync(outputPath, { recursive: true })
fs.writeFileSync(path.join(outputPath, 'string.js'), content)
fs.writeFileSync(path.join(outputPath, 'string.d.ts'), 'export declare const workerString: string\n')
}
4 changes: 3 additions & 1 deletion packages/worker/string/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"private": true,
"main": "../bundle/workerString.ts"
"main": "../cjs/entries/string.js",
"module": "../esm/entries/string.js",
"types": "../cjs/entries/string.d.ts"
}