-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Unexpected token
when wmr build
with importing i18next
#769
Comments
Without > wmr build --prerender --debug
wmr:config {
wmr:config _: [],
wmr:config prerender: true,
wmr:config debug: true,
wmr:config cwd: '/Users/riywo/work/wmr-i18next',
wmr:config public: 'public',
wmr:config out: '/Users/riywo/work/wmr-i18next/dist',
wmr:config sourcemap: undefined,
wmr:config visualize: undefined,
wmr:config minify: true,
wmr:config root: '/Users/riywo/work/wmr-i18next/public',
wmr:config plugins: [],
wmr:config output: [],
wmr:config middleware: [],
wmr:config features: { preact: true },
wmr:config alias: { react: 'preact/compat', 'react-dom': 'preact/compat' },
wmr:config customRoutes: [],
wmr:config prod: true,
wmr:config mode: 'build',
wmr:config env: {},
wmr:config overlayDir: '/Users/riywo/work/wmr-i18next/dist',
wmr:config publicPath: '/',
wmr:config host: 'localhost'
wmr:config }
npm:plugin preact-iso -> npm/[email protected]/index.js
npm:plugin preact-iso -> npm/[email protected]/index.js
npm:plugin preact/hooks -> npm/[email protected]/hooks/dist/hooks.module.js
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin ./router.js -> npm/[email protected]/router.js
npm:plugin ./lazy.js -> npm/[email protected]/lazy.js
npm:plugin ./hydrate.js -> npm/[email protected]/hydrate.js
npm:plugin ./prerender.js -> npm/[email protected]/prerender.js
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin preact/hooks -> npm/[email protected]/hooks/dist/hooks.module.js
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin preact/hooks -> npm/[email protected]/hooks/dist/hooks.module.js
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin preact-render-to-string -> npm/[email protected]/dist/index.mjs
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin htm/preact -> npm/[email protected]/preact/index.module.js
npm:plugin htm/preact -> npm/[email protected]/preact/index.module.js
npm:plugin htm/preact -> npm/[email protected]/preact/index.module.js
npm:plugin htm/preact -> npm/[email protected]/preact/index.module.js
npm:plugin htm/preact -> npm/[email protected]/preact/index.module.js
npm:plugin preact -> npm/[email protected]/dist/preact.module.js
npm:plugin htm -> npm/[email protected]/dist/htm.module.js
minify(index.e7dc04ec.js) took 793ms
minify(chunks/prerender.5e4dbeff.js) took 170ms
Merging assets/style.module.83820528.css into assets/style.module.7b16dcc3.css (chunks/index.85d8c93a.js → index.e7dc04ec.js)
Hoisting CSS "assets/style.module.7b16dcc3.css" imported by index.e7dc04ec.js into parent HTML import "assets/style.e6ee4bcf.css".
Wrote 23Kb to disk:
dist/index.html 460b
dist/index.e7dc04ec.js 17Kb
dist/assets/style.e6ee4bcf.css 499b
dist/chunks/index.85d8c93a.js 214b
dist/chunks/prerender.5e4dbeff.js 4.8Kb
Prerendered 3 pages:
/
/about [from /]
/error [from /] |
Captured the actual error by development env:
Exception:
Code is here:
|
It seems
|
Minimal repro: const acorn = require("acorn");
const {importAssertions} = require('acorn-import-assertions');
const fs = require('fs');
const code = fs.readFileSync("/Users/riywo/GitHub/wmr/examples/demo/node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js", "utf8");
console.log(code)
console.log(acorn.parse(code, {sourceType: "module"})) // No issue
console.log(acorn.Parser.extend(importAssertions).parse(code, {sourceType: "module"})) // Unexpected token |
With the fix above,
|
Awesome debugging @riywo!! |
Just FYI: |
It looks like the if I rename the |
Reopening, per the above comment. |
Describe the bug
When I import
i18next
,wmr start
(development) has no issue and works expectedly. However,wmr build
fails with a weird error below. There is no clue from the debug output.To Reproduce
Steps to reproduce the behavior:
npm init wmr app
cd app && npm install i18next
import i18n from "i18next"
topublic/index.js
npm run build
Expected behavior
No build failure since
wmr start
has no issue and application is running.Bug occurs with:
wmr
orwmr start
(development)wmr build
(production)wmr serve
Desktop (please complete the following information):
Additional context
N/A
The text was updated successfully, but these errors were encountered: