-
Notifications
You must be signed in to change notification settings - Fork 163
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
Incompatibility with 3.x.x and sst v2 #844
Comments
Hi there 👋 This is most likely an issue with the Node version. In Node 22 removed import assertions, and replaced them with import attributes, but they were only patched into specific older node versions. Can you try one of these Node versions
|
This is my engine config and my local build version is Node v21.7.3.
So far my very hacky and unsatisfying work around is to use a vite plugin: // vite-import-assertion-plugin.ts
import { transformAsync } from '@babel/core';
import { Plugin } from 'vite';
export default function importAssertionPlugin(): Plugin {
return {
name: 'vite-plugin-import-assertion',
async transform(code: string, id: string): Promise<string | undefined> {
if (id.includes('node_modules') || !id.endsWith('.mjs')) {
return undefined;
}
const result = await transformAsync(code, {
filename: id,
plugins: [
['@babel/plugin-syntax-import-assertions'],
],
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
],
});
return result?.code ?? undefined;
},
};
} // vite.config.ts
...
import importAssertionPlugin from './vite-import-assertion-plugin';
...
plugins: [
importAssertionPlugin(),
remix({
ignoredRouteFiles: ["**/.*"],
}),
tsconfigPaths(),
],
... // stacks/stacks.ts
const site = new RemixSite(stack, "site", {
...
nodejs: {
esbuild: {
external: ["@aws-sdk/*"],
loader: {
'.json': 'json',
},
plugins:[
{
name: 'import-assertion',
setup(build) {
build.onLoad({ filter: /\.mjs$/ }, async (args) => {
const fs = require('fs');
let contents = await fs.promises.readFile(args.path, 'utf8');
contents = contents.replace(/import .+ from .+ with { type: 'json' };/g, (match) => {
return match.replace(' with { type: \'json\' }', '');
});
return { contents, loader: 'js' };
});
},
}
]
},
},
.... |
Thank you for the update. And glad to hear you found a workaround for now. If you are able to provide a minimal repo to reproduce this, as well as the Node versions you are using, we may be able to look into this further to see if there is a better solution for your use case. |
same problem to me. execute the
|
Getting this nasty error when I try to updates
@shopify/shopify-app-remix
from2.8.2
to3.x.x
. I am running sst v2 (2.43.7
) with RemixSite set to build with node 20.x :runtime: "nodejs20.x"
Would love to upgrade so I can get the latest APIs from shopify, but seems like there use of new attributes is causing problems.
The text was updated successfully, but these errors were encountered: