For my Flutter project, I have my dependencies setup as such:
// Dependencies
// ------------
// Packages
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
// Widgets
import '../widgets/ring-swipe.dart';
However, when I use Reformat Code in IntelliJ, my comments turn into:
// Dependencies
// ------------
// Packages
import 'package:cached_network_image/cached_network_image.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../widgets/ring-swipe.dart';
I can't seem to find where this setting is set for Dart/Flutter projects. Is this non-configurable?
This behavior seems related to issue IDEA-171179 (and duplicates), which is still open, unfortunately.
See, specifically, this Dart example, which seems to match.
Before reformat code:
// ignore: unused_import
import 'package:polymer_elements/iron_flex_layout_classes.dart';
// ignore: unused_import
import 'package:polymer_elements/app_layout/app_header/app_header.dart';
After reformat code:
import 'package:polymer_elements/iron_flex_layout_classes.dart';
import 'package:polymer_elements/app_layout/app_header/app_header.dart';
// ignore: unused_import
// ignore: unused_import
Valid for the old IDEA 2017.1
To mitigate the issue, remove the Optimize imports check.
Related
For my RN project, I use '#videosdk.live/react-native-sdk'.When I try to import a method from the library I get undefined. I can't figure out what's going on. I did everything according to the instruction and set it up correctly.
The problem is not even in the setup, but I installed the package '#videosdk.live/react-native-sdk', but I can't import methods from it.
import VideoSdk from '#videosdk.live/react-native-sdk'; I used this import but got undefined
You can't import VideoSdk. You need to import some other components like:
import {
MeetingProvider,
useMeeting,
useParticipant,
MediaStream,
RTCView,
} from "#videosdk.live/react-native-sdk";
In QML-only application (so no backend) I'd like to have an optional import of a javascript file. If the optional library is present then the user has extra functionalities.
A regular:
import "xyz.js" as SoloAnalyzer
fails if the library is not found.
A try/catch is not valid on import statements:
try {
import "xyz.js" as SoloAnalyzer
}
What are the other options ? Thanks.
IMPORTANT: I'm limited to these versions : QtQuick 2.9 and QtQuick.Controls 2.2
My vue-cli version is 4.5.15, but it cannot resolve # as ./src and all paths using '#' are not found. Why did this happen and how could I solve it?
Your statement tries to import a file which does not exist: import Layout from '#/layout' would work with layout.vue or layout/index.js, neither of which is present.
To fix this, you can either import the single components with their full path (as mentioned in #wittgenstein's comment): import Footer from '#/layout/Footer'
Or you can create layout/index.js which exposes all components inside the directory:
import Footer from './Footer.vue'
import Header from './Header.vue'
// ...
export default {
Footer, Header, // ...
}
Then you can import components like that: import { Footer, Header } from '#/layout'
It is not possible to import a folder, you will have to import a single file from the layout folder:
import Footer from "#/Layout/Footer.vue"
import Header from "#/Layout/Header.vue"
import Index from "#/Layout/Index.vue"
import Sidebar from "#/Layout/Sidebar.vue"
import Sidebar2 from "#/Layout/Sidebar2.vue"
If you want to import every file, you will have to this all manually, because you cannot import a folder.
Hope this will work for you!
I have known what the problem is. It's because I used 'Index.vue' as the name before and git is insensitive to capital. So it cannot find the path.
Vue has supported
import xxx from "#/xxx"
if the name of your file you want to import is "index.vue".
Thanks a lot for your answers!
I simply wanted to import lodash import _ from 'lodash';, and I keep having the following error:
rollup v2.23.0
bundles src/main.js → public\build\bundle.js...
[!] (plugin commonjs) SyntaxError: Unexpected token (434:48) in C:\my-svelte\node_modules\lodash\lodash.js
node_modules\lodash\lodash.js (434:48)
432:
433: /** Detect free variable `process` from Node.js. */
434: var freeProcess = moduleExports && freeGlobal.process;
^
435:
436: /** Used to access faster Node.js helpers. */
SyntaxError: Unexpected token (434:48) in C:\my-svelte\node_modules\lodash\lodash.js
at Object.pp$4.raise (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:15135:13)
at Object.pp.unexpected (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:12906:8)
at Object.pp$3.parseIdent (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:15086:10)
at Object.parseIdent (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:18737:27)
at Object.parseIdent (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:18969:27)
at Object.pp$3.parseSubscript (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14380:62)
at Object.parseSubscript (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:18640:37)
at Object.pp$3.parseSubscripts (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14355:24)
at Object.pp$3.parseExprSubscripts (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14340:21)
at Object.pp$3.parseMaybeUnary (C:\my-svelte\node_modules\rollup\dist\shared\rollup.js:14314:17)
I used npx degit sveltejs/template my-svelte to create the app.
I tried lodash-es as well, same thing: [!] (plugin commonjs) SyntaxError: Unexpected token (13:46) in C:\my-svelte\node_modules\lodash-es_nodeUtil.js.
This is definitely a lodash related issue, specifically related to that line 434. Everything else I tried to import works just fine:
import {v4} from 'uuid';
import {Subject} from "rxjs";
import ReconnectingWebSocket from 'reconnecting-websocket';
...
EDIT: The problem is caused by import replace from '#rollup/plugin-replace'; in rollup.config.js :(
Now I need to figure out how to get .env variables into Svelte without #rollup/plugin-replace...
I use lodash-es and works fine. I even get nice tree-shaking with that.
<script>
import { upperCase } from 'lodash-es';
export let name;
</script>
<p>{upperCase(name)}</p>
Edit
The answer was pretty old and code improves: my application now uses this to import lodash on a svelte file for quite a while - I hope it works for the OP also now:
import _ from "lodash";
Old Post
(a commenter mentioned that this does not work anymore, for whatever reasons - I leave it just here)
This works for me in my svelte files:
<script>
const _ = require('lodash');
//...
</script>
I often get into trouble with import on my electron/svelte project but require usually helps.
I am trying to use flow in my current react-native project. After some research, I discovered that all the types I need are in this file, but I have no idea how I am supposed to import these types.
For instance, I need to import the ViewLayoutEvent from there. What am I supposed to write in my file?
I tried the following:
import type { ViewLayoutEvent } from 'react-native';
import type { ViewLayoutEvent } from 'react-native/Libraries/Components/View/ViewPropTypes';
To no avail.
Update:
Or maybe it is in this file