-
Notifications
You must be signed in to change notification settings - Fork 3
Doesn't work with nextjs 13.1 #19
Comments
Adding from the example from effector/swc-plugin#18
Simple test describe('describe', () => {
test('test', () => {
expect(1).toEqual(1);
})
}); Error
It seems |
I tried to recompile a lib locally with newer versions of SWC deps. That didn't help. But I didn't manage to build it with Rust stable channel because one of the deps (not a swc failed). So i installed latest nightly, and don't know now it panics because of nightly rust or because of deps mismatch. |
Check |
With 0.0.7 I receive another error, now from plugins sources:
|
Related and might be interesting to others swc-project/swc#6807 |
Should be fixed by #26. Can you please try it out? |
The error changed, now it's
I will try to isolate broken code later one and post it here. |
I've found a root cause. This happens only when Do the effector plugin somehow directly consume or manipulate sourcemaps? PS i'm the author of .swcrc {
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"transform": {
"react": {
"runtime": "automatic",
"importSource": "@emotion/react"
}
},
"target": "es2020",
"loose": false,
"externalHelpers": false,
"keepClassNames": false,
"experimental": {
"plugins": [
["@lingui/swc-plugin", {}],
["@effector/swc-plugin", {}],
]
}
},
"minify": false
} npx swc ./component.tsx -d dist-swc --config-file="./.swcrc" // component.tsx
import Script from 'next/script';
import { ConsentManager } from '@segment/consent-manager';
import { Trans, t } from '@lingui/macro';
import { PreferenceDialogTemplate } from '@segment/consent-manager/types/types';
import { css } from '@emotion/react';
import { zIndex } from '@/styles/z-index';
type Props = {
segmentKey: string;
isEnabled: boolean;
bannerAsModal: boolean;
};
const bannerCss = css`
position: fixed;
bottom: 0;
z-index: ${zIndex.segment};
width: 100%;
display: block;
`;
export const SegmentSnippet = (props: Props) => {
const template: PreferenceDialogTemplate = {
headings: {
allowValue: t`Allow`,
categoryValue: t`Category`,
purposeValue: t`Purpose`,
toolsValue: t`Tools`,
},
checkboxes: {
noValue: t`No`,
yesValue: t`Yes`,
},
actionButtons: {
cancelValue: t`Cancel`,
saveValue: t`Save`,
},
cancelDialogButtons: {
cancelValue: t`Yes, Cancel`,
backValue: t`Go Back`,
},
categories: [
{
key: 'functional',
name: t`Functional`,
description:
t`To monitor the performance of our site and to enhance your browsing experience.`,
example: t`For example, these tools enable you to communicate with us via live chat.`,
},
{
key: 'marketing',
name: t`Marketing and Analytics`,
description:
t`To understand user behavior in order to provide you with a more relevant browsing experience or personalize the content on our site.`,
example:
t`For example, we collect information about which pages you visit to help us present more relevant information.`,
},
{
key: 'advertising',
name: t`Advertising`,
description:
t`To personalize and measure the effectiveness of advertising on our site and other websites.`,
example:
t`For example, we may serve you a personalized ad based on the pages you visit on our site.`,
},
{
key: 'essential',
name: t`Essential`,
description: t`We use browser cookies that are necessary for the site to work as intended.`,
example:
t`For example, we store your website data collection preferences so we can honor them if you return to our site. You can disable these cookies in your browser settings but if you do the site may not work as intended.`,
},
],
};
const bannerContent = (
<span>
<Trans>
We use cookies (and other similar technologies) to collect data to improve your experience on
our site. By using our website, you’re agreeing to the collection of data as described in our{' '}
<a href="https://road.travel/welcome/en/privacy/" rel="noreferrer" target="_blank">
Website Data Collection Policy
</a>
.
</Trans>
</span>
);
const bannerSubContent = t`You can change your preferences at any time.`;
const preferencesDialogTitle = t`Data Collection Settings`;
const preferencesDialogContent =
t`We use data collected by cookies and JavaScript libraries to improve your browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.`;
const cancelDialogTitle = t`Are you sure you want to cancel?`;
const cancelDialogContent =
t`Your preferences have not been saved. By continuing to use our website, you՚re agreeing to our Website Data Collection Policy.`;
return (
<>
<Script
id="show-banner"
dangerouslySetInnerHTML={{
__html: `!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};;analytics.SNIPPET_VERSION="4.13.2";
analytics.page();
}}();`,
}}
/>
<div css={bannerCss}>
<ConsentManager
writeKey={props.segmentKey}
bannerContent={bannerContent}
bannerSubContent={bannerSubContent}
bannerAsModal={props.bannerAsModal}
preferencesDialogTitle={preferencesDialogTitle}
preferencesDialogContent={preferencesDialogContent}
cancelDialogTitle={cancelDialogTitle}
cancelDialogContent={cancelDialogContent}
bannerActionsBlock={true}
preferencesDialogTemplate={template}
shouldRequireConsent={() => props.isEnabled}
bannerHideCloseButton={true}
/>
</div>
</>
);
}; As you see there are no calls to effector in this file, but plugin still trying to apply some logic. |
@Drevoed It seems you need to check for if ident.span.lo.is_dummy() {
let loc = self.cm.lookup_char_pos(ident.span.lo);
self.state.loc = Some(loc);
} Because // .cargo/registry/src/github.com-1ecc6299db9ec823/swc_common-0.29.27/src/syntax_pos.rs
impl BytePos {
// ...
/// Returns true if this is synthesized and has no relevant input source
/// code.
pub const fn is_dummy(self) -> bool {
self.0 == 0
}
} Here is possible the same root cause of issue: effector/swc-plugin#18 (comment) |
It's probably caused by a version mismatch between SWC version used in nextjs and SWC crates this plugin build with. Probably bumping to
Should help
The text was updated successfully, but these errors were encountered: