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

fix: remove inline script source-url #2850

Merged
merged 4 commits into from
Dec 21, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/shared/src/assets-transpilers/__tests__/script.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { expect, it } from 'vitest';
import transpileScript from '../script';
import { StandardSandbox } from '../../../../sandbox/src/core/sandbox/StandardSandbox';
wanghangit marked this conversation as resolved.
Show resolved Hide resolved

it('inline script not include sourceURL', () => {
const scriptElement = document.createElement('script');
scriptElement.innerHTML = 'console.log("hello world")';
const sandboxInstance = new StandardSandbox("app", {});
const publicPath = 'http://localhost:8000';
const transpiledScriptElement = transpileScript(scriptElement, publicPath, {fetch: window.fetch, rawNode: scriptElement, sandbox: sandboxInstance});
expect(transpiledScriptElement.innerHTML).toEqual(expect.not.stringContaining(`//# sourceURL=${publicPath}`));
});
2 changes: 1 addition & 1 deletion packages/shared/src/assets-transpilers/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default function transpileScript(
const scriptNode = script.textContent ? script : rawNode.childNodes[0];
const { code } = result;

scriptNode.textContent = sandbox!.makeEvaluateFactory(code, baseURI);
scriptNode.textContent = sandbox!.makeEvaluateFactory(code);
// mark the script have consumed
script.dataset.consumed = 'true';

Expand Down