-
Notifications
You must be signed in to change notification settings - Fork 59
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
Support for dynamic import()
#352
Comments
had to disable linter until ipfs/aegir#352 is fixed
Updating this issue to capture all the Browser tests in Karma are also breaking on
You can reproduce both of these issues by pulling down https://github.com/ipld/js-ipld-stack and running |
Running which command with |
|
My output from $ npx aegir lint
/home/vmx/src/pl/js-ipld-stack/src/path-level-zero.js
11:7 warning Unexpected 'todo' comment no-warning-comments
33:7 warning Unexpected 'todo' comment no-warning-comments
54:7 warning Unexpected 'todo' comment no-warning-comments
/home/vmx/src/pl/js-ipld-stack/src/get-codec/index-browser.js
17:20 error Parsing error: Unexpected token import
/home/vmx/src/pl/js-ipld-stack/src/get-codec/index-nodejs.js
4:3 error Unnecessarily quoted property 'raw' found quote-props
✖ 5 problems (2 errors, 3 warnings)
1 error and 0 warnings potentially fixable with the `--fix` option.
Lint errors
Error: Lint errors
at Promise (/home/vmx/src/pl/js-ipld-stack/node_modules/aegir/src/lint.js:88:21)
at process._tickCallback (internal/process/next_tick.js:68:7) An my out put from …
Test Browser
ℹ 「wdm」:
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...
✖ 「wdm」:
ERROR in ./src/get-codec/index-browser.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/vmx/src/pl/js-ipld-stack/src/get-codec/index-browser.js: Support for the experimental syntax 'dynamicImport' isn't currently enabled (17:20):
15 | }
16 | if (codec === 'dag-cbor') {
> 17 | cache[codec] = import('../dag-cbor').then(resolve)
| ^
18 | }
19 | if (codec === 'dag-json') {
20 | cache[codec] = import('../dag-json').then(resolve)
Add @babel/plugin-syntax-dynamic-import (https://git.io/vb4Sv) to the 'plugins' section of your Babel config to enable parsing.
at Object.raise (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:3851:17)
at Object.expectPlugin (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5172:18)
at Object.parseExprAtom (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:6180:14)
at Object.parseExprSubscripts (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5914:23)
at Object.parseMaybeUnary (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5894:21)
at Object.parseExprOps (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5781:23)
at Object.parseMaybeConditional (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5754:23)
at Object.parseMaybeAssign (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5701:21)
at Object.parseMaybeAssign (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:2639:18)
at Object.parseMaybeAssign (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5740:25)
at Object.parseMaybeAssign (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:2639:18)
at Object.parseExpression (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:5649:23)
at Object.parseStatementContent (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:7420:23)
at Object.parseStatement (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:7291:17)
at Object.parseStatement (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:1993:26)
at Object.parseBlockOrModuleBlockBody (/home/vmx/src/pl/js-ipld-stack/node_modules/@babel/parser/lib/index.js:7868:25)
@ ./src/block.js 7:17-39
@ ./test/block.spec.js
@ ./test sync \.spec\.js$
@ ./node_modules/aegir/src/config/karma-entry.js
ℹ 「wdm」: Failed to compile.
… Are you running an old version? I run 18.2.2. |
I edited the output to only show the relevant parts, if you look at your output you’ll see the output I noted in both of them :) |
@mikeal You're absolutely right. It's late here… |
This is going to end up being a blocker for |
In the new IPLD stack we’re using the import function to dynamically load codecs in the browser w/ automatic code splitting from webpack.
I’m trying to move the tests and linting in the project to aegir and it’s breaking on
import()
.This can only be resolved by either:
babel-eslint
which is a sizable change and is slower than the current configuration.Unfortunately, I can’t disable eslint in the file because it breaks on tokenizing the file which is a step before any disable comments are parsed.
UPDATE: Read below for another
import()
related issue. Title has been updated to account for both.The text was updated successfully, but these errors were encountered: