Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

Import statement isn't working #3

Closed
mehanalavimajd opened this issue Jun 29, 2021 · 17 comments
Closed

Import statement isn't working #3

mehanalavimajd opened this issue Jun 29, 2021 · 17 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@mehanalavimajd
Copy link
Contributor

mehanalavimajd commented Jun 29, 2021

I added this to Render function:

export default function render ...

And made a test script :

import render from "../dist/applecake.js"

But it make a error:
Uncaught SyntaxError: Cannot use import statement outside a module
@amirghazi87 and @PooiaFerdowsi do you know how to fix it ?

@adabadadudu
Copy link
Contributor

can you add directory structure ? (use tree command)

@mehanalavimajd
Copy link
Contributor Author

.
├── CONTRIBUTING.md
├── dist
│ ├── applecake.js
│ ├── applecake.js.map
│ └── typescript
│ └── applecake.ts
├── distpacker.js
├── docs
│ ├── 01-basics
│ │ ├── 1.installation.md
│ │ └── 2.CRH.md
│ ├── 02-Rendering
│ │ ├── 1.components.md
│ │ └── 2.Render&insert.md
│ └── 03-IdManager
│ └── 01.edit.md
├── images
│ ├── CRH.png
│ └── first-view.PNG
├── lib
│ ├── ID
│ │ ├── Manager
│ │ │ └── idmanager.ts
│ │ └── Select
│ │ └── idselector.ts
│ ├── Insert
│ │ └── insert.ts
│ └── Render
│ └── render.ts
├── LICENSE
├── Makefile
├── node_modules
│ ├── ansi-styles
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── license
│ │ ├── package.json
│ │ └── readme.md
│ ├── chalk
│ │ ├── index.d.ts
│ │ ├── license
│ │ ├── package.json
│ │ ├── readme.md
│ │ └── source
│ │ ├── index.js
│ │ ├── templates.js
│ │ └── util.js
│ ├── color-convert
│ │ ├── CHANGELOG.md
│ │ ├── conversions.js
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── README.md
│ │ └── route.js
│ ├── color-name
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── has-flag
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── license
│ │ ├── package.json
│ │ └── readme.md
│ └── supports-color
│ ├── browser.js
│ ├── index.js
│ ├── license
│ ├── package.json
│ └── readme.md
├── package.json
├── package-lock.json
├── packer.js
├── README.md
├── test
│ ├── h.html
│ └── h.js
├── TODO.md
└── tsconfig.json
thats it @PooiaFerdowsi

@mehanalavimajd mehanalavimajd pinned this issue Jun 29, 2021
@mehanalavimajd mehanalavimajd added the bug Something isn't working label Jun 29, 2021
@adabadadudu
Copy link
Contributor

h.html and h.js are you file ??

I think you should remove test directory and put your codes in root of your dir structure

it's maybe help

@mehanalavimajd
Copy link
Contributor Author

Ok let me test it

@mehanalavimajd
Copy link
Contributor Author

I put h.js and h.html in root of directory but It again make that error .
and I have added this:

<script type="module" src="h.js"></script>

after adding "type=module" there is no error but nothing will happen i mean nothing will be rendered on browser @PooiaFerdowsi .

@mehanalavimajd
Copy link
Contributor Author

I think we should add a wont'fix label if you havent got an idea @PooiaFerdowsi .

@mehanalavimajd mehanalavimajd added the wontfix This will not be worked on label Jul 1, 2021
@adabadadudu
Copy link
Contributor

Oh , are you sure that function name is render no Render ??

It's now new , it's happened for me but I don't know about js . currently I've learn html/css !

So I have some guesses for that error:

The Uncaught SyntaxError: Cannot use import statement outside a module error is very readable .

See following dir stuct

-module
__libs(html|css|js)
-test
__codes.(html|css|js)

@mehanalavimajd
Copy link
Contributor Author

Hello, yeah Render is correct but it again give that error . I didn't understand what u Mean about directory structure

@adabadadudu
Copy link
Contributor

if you experience in python , please see following source:

-module
__libs.py
-test
__codes.py

libs.py:

def somefn():
   ....

codes.py:

import ../libs.py

now where is __pycache__ directory ??

@mehanalavimajd
Copy link
Contributor Author

I think pycache would be in test dir .
But how does this will help in js import error?

@adabadadudu
Copy link
Contributor

I think python will raise error.

but js is like py in this station

@mehanalavimajd
Copy link
Contributor Author

Hey @PooiaFerdowsi , applecake is going to replace with a new library (look readme) . And I want to suggest some names please if you can 🙏.

@adabadadudu
Copy link
Contributor

Unfortunately I am not well for naming.

if it war created by me, I call it jslfw (JavaScriptLittleFrameWork) because I don't have any name for project

@mehanalavimajd
Copy link
Contributor Author

@PooiaFerdowsi I chose panix name for new library and I fix this issue . Would you like to join me at panix (you should know js)?

@adabadadudu
Copy link
Contributor

I know primary of javascript and i liket to join

@mehanalavimajd
Copy link
Contributor Author

You are best :)

@mehanalavimajd
Copy link
Contributor Author

please come to panix library

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants