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: resolve side effect imports #12062

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/heavy-ties-worry.md
@@ -0,0 +1,5 @@
---
"@sveltejs/package": patch
---

fix: resolve side effect imports
2 changes: 1 addition & 1 deletion packages/package/src/utils.js
Expand Up @@ -30,7 +30,7 @@ export function resolve_aliases(input, file, content, aliases) {
return match;
};

content = content.replace(/from\s+('|")([^"';,]+?)\1/g, replace_import_path);
content = content.replace(/(?:import|from)\s*('|")([^"';,]+?)\1/g, replace_import_path);
content = content.replace(/import\s*\(\s*('|")([^"';,]+?)\1\s*\)/g, replace_import_path);
return content;
}
Expand Down
@@ -1,4 +1,5 @@
<script>
import './css/global.css';
import { foo } from './sub/foo';
import { util } from './utils';
export let bar = foo;
Expand Down
@@ -1,4 +1,5 @@
import { SvelteComponent } from 'svelte';
import './css/global.css';
declare const __propDef: {
props: {
bar?: import('./sub/foo').Foo;
Expand Down
@@ -0,0 +1 @@
/* some css to test if side effect imports are resolved */
@@ -1,4 +1,6 @@
<script lang="ts">
import '$lib/css/global.css';

import { foo } from '$lib/sub/foo';
import { util } from '$utils';

Expand Down
@@ -0,0 +1 @@
/* some css to test if side effect imports are resolved */