Skip to content

Commit

Permalink
Chore: add test case for importing swc/helpers in script without module
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Jan 23, 2022
1 parent e1a88ed commit f040669
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/core/integration-tests/test/html.js
Expand Up @@ -1408,6 +1408,30 @@ describe('html', function () {
assert(errored);
});

it('should not includes imports of @swc/helpers in scripts without type="module"', async function () {
await bundle(
path.join(
__dirname,
'/integration/html-js-not-import-swc-handler-on-script/index.html',
),
{
defaultTargetOptions: {
engines: {
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
browsers: 'Chrome 48',
},
},
},
);

let html = await outputFS.readFile(
path.join(distDir, 'index.html'),
'utf8',
);
assert(!html.includes('swc/helpers'));
assert(html.includes('_slicedToArray'));
});

it('should allow imports and requires in inline <script> tags', async function () {
let b = await bundle(
path.join(__dirname, '/integration/html-inline-js-require/index.html'),
Expand Down
@@ -0,0 +1,9 @@
<html>
<script>
function arr() {
return [1, 2, 3];
}
const [a, b, c] = arr();
console.log(a, b, c);
</script>
</html>

0 comments on commit f040669

Please sign in to comment.