Module parse failed: Unexpected token (1:935)
File was processed with these loaders:
* ../node_modules/babel-loader/lib/index.js
* ../node_modules/@snowpack/plugin-webpack/plugins/import-meta-fix.js
* ../node_modules/@snowpack/plugin-webpack/plugins/proxy-import-resolve.js
You may need an additional loader to handle the result of these loaders.
> import React,{useState}from"../../pkg/react.js";import{useArray}from"../../atomic-react/hooks.js";import{ButtonMargin}from"../Button.js";import{ErrMessage}from"./InputStyles.js";import{ResourceSelector}from"./ResourceSelector.js";export default function InputResourceArray({resource,property,required}){const[array,setArray]=useArray(resource,property.subject);const[err,setErr]=useState(null);function handleAdd(){array.push(null);const newArray=array;setArray(newArray);}function handleRemove(index){array.splice(index,1);const newArray=array;setArray(newArray);}function handleSetSubject(value,handleErr,index){array[index]=value;setArray(array,handleErr);}return/* @__PURE__ */React.createElement(React.Fragment,null,array.map((subject,index)=>/* @__PURE__ */React.createElement(ResourceSelector,{key:`${property.subject}${index}${subject}`,value:subject,setSubject:(set,handleErr)=>handleSetSubject(set,handleErr,index),error:err?.index==index&&err,setError:setErr,classType:property.classType,required,handleRemove:()=>handleRemove(index)})),/* @__PURE__ */React.createElement(ButtonMargin,{subtle:true,type:"button",onClick:handleAdd},"add"),err?.index==void 0&&/* @__PURE__ */React.createElement(ErrMessage,null,err?.message),array==[]&&/* @__PURE__ */React.createElement(ErrMessage,null,"Required"));}
If we look at the unexpected token at 1:935, we get a question mark ?. operator for optional chaining, which is an ES2020 feature. So, I've tried setting the compilation target in compilerOptions in tsconfig.json from es2020 to es6, but to no avail. Also tried setting tsconfig's jsx: "preserve", to react. Also tried this suggested fix. Whenever I use snowpack builder (so disabling @snowpack/plugin-webpack), things work fine. That would mean having a bigger bundle size, but maybe that's the best solution as of now.
npm run build
is failing (since.. upgrading most dependencies).throwing errors like this:
If we look at the
unexpected token
at1:935
, we get a question mark?.
operator for optional chaining, which is an ES2020 feature. So, I've tried setting the compilation target incompilerOptions
intsconfig.json
fromes2020
toes6
, but to no avail. Also tried setting tsconfig'sjsx: "preserve",
toreact
. Also tried this suggested fix. Whenever I use snowpack builder (so disabling@snowpack/plugin-webpack
), things work fine. That would mean having a bigger bundle size, but maybe that's the best solution as of now.