@surma/rollup-plugin-off-main-thread
Advanced tools
Comparing version 1.2.0 to 1.3.0
10
index.js
@@ -45,4 +45,2 @@ /** | ||
const prefix = `"${opts.marker}_start" + import(`; | ||
const suffix = `) + "${opts.marker}_end"`; | ||
const urlLoaderPrefix = opts.urlLoaderScheme + ":"; | ||
@@ -98,3 +96,3 @@ | ||
if (!/^\.*\//.test(workerFile)) { | ||
if (!new RegExp("^.*/").test(workerFile)) { | ||
this.warn( | ||
@@ -106,3 +104,3 @@ `Paths passed to the Worker constructor must be relative or absolute, i.e. start with /, ./ or ../ (just like dynamic import!). Ignoring "${workerFile}".` | ||
const resolvedWorkerFile = await this.resolveId(workerFile, id); | ||
const resolvedWorkerFile = (await this.resolve(workerFile, id)).id; | ||
workerFiles.push(resolvedWorkerFile); | ||
@@ -130,2 +128,6 @@ const chunkRefId = this.emitFile({ | ||
resolveFileUrl(chunk) { | ||
return `"./${chunk.fileName}"`; | ||
}, | ||
renderChunk(code, chunk, outputOptions) { | ||
@@ -132,0 +134,0 @@ if (outputOptions.format !== "amd") { |
{ | ||
"name": "@surma/rollup-plugin-off-main-thread", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Use Rollup with workers and ES6 modules today.", | ||
@@ -23,3 +23,3 @@ "main": "index.js", | ||
"prettier": "1.18.2", | ||
"rollup": "1.31.1" | ||
"rollup": "2.0.0-0" | ||
}, | ||
@@ -26,0 +26,0 @@ "repository": { |
@@ -22,34 +22,49 @@ /** | ||
async function fileExists(file) { | ||
try { | ||
const stat = await fs.promises.stat(file); | ||
return stat.isFile(); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
async function init() { | ||
[ | ||
"./tests/fixtures/simple-bundle/entry.js", | ||
"./tests/fixtures/import-meta/entry.js", | ||
"./tests/fixtures/dynamic-import/entry.js", | ||
"./tests/fixtures/public-path/entry.js", | ||
"./tests/fixtures/worker/entry.js", | ||
"./tests/fixtures/more-workers/entry.js", | ||
"./tests/fixtures/amd-function-name/entry.js", | ||
"./tests/fixtures/single-default/entry.js", | ||
"./tests/fixtures/import-worker-url/entry.js", | ||
"./tests/fixtures/import-worker-url-custom-scheme/entry.js" | ||
].forEach(async input => { | ||
const pathName = path.dirname(input); | ||
let config = {}; | ||
try { | ||
const configPath = path.join(pathName, "config.json"); | ||
config = JSON.parse(fs.readFileSync(configPath).toString()); | ||
} catch (e) {} | ||
const bundle = await rollup.rollup({ | ||
input, | ||
await Promise.all( | ||
[ | ||
"./tests/fixtures/simple-bundle/entry.js", | ||
"./tests/fixtures/import-meta/entry.js", | ||
"./tests/fixtures/dynamic-import/entry.js", | ||
"./tests/fixtures/public-path/entry.js", | ||
"./tests/fixtures/worker/entry.js", | ||
"./tests/fixtures/more-workers/entry.js", | ||
"./tests/fixtures/amd-function-name/entry.js", | ||
"./tests/fixtures/single-default/entry.js", | ||
"./tests/fixtures/import-worker-url/entry.js", | ||
"./tests/fixtures/import-worker-url-custom-scheme/entry.js", | ||
"./tests/fixtures/assets-in-worker/entry.js" | ||
].map(async input => { | ||
const pathName = path.dirname(input); | ||
let rollupConfig = { | ||
input, | ||
strictDeprecations: true | ||
}; | ||
const rollupConfigPath = "./" + path.join(pathName, "rollup.config.js"); | ||
const configPath = "./" + path.join(pathName, "config.json"); | ||
if (await fileExists(rollupConfigPath)) { | ||
require(rollupConfigPath)(rollupConfig, omt); | ||
} else if (await fileExists(configPath)) { | ||
rollupConfig.plugins = [omt(require(configPath))]; | ||
} else { | ||
rollupConfig.plugins = [omt()]; | ||
} | ||
const bundle = await rollup.rollup(rollupConfig); | ||
const outputOptions = { | ||
dir: path.join(pathName, "build"), | ||
format: "amd" | ||
}; | ||
await bundle.write(outputOptions); | ||
}) | ||
); | ||
plugins: [omt(config)] | ||
}); | ||
const outputOptions = { | ||
dir: path.join(pathName, "build"), | ||
format: "amd" | ||
}; | ||
await bundle.generate(outputOptions); | ||
await bundle.write(outputOptions); | ||
}); | ||
const karmaConfig = { port: 9876 }; | ||
@@ -56,0 +71,0 @@ myKarmaConfig({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71232
71
1127
4
2