ProjectEvergreen / wcc

Experimental native Web Components compiler.
https://merry-caramel-524e61.netlify.app
90 stars 7 forks source link

adopt a bundle friendly and ESM compatible version of acorn-jsx #142

Closed thescientist13 closed 8 months ago

thescientist13 commented 9 months ago

Summary

In needing to open up Rollup to additional exportConditions in Greenwood, it has become a bit of a blocker that acorn-jsx is not in ESM, which causes issue when going through Node's ESM loader.

Otherwise, we will get this error

  Error when using sourcemap for reporting an error: Can't resolve original location of error.
Error: 'default' is not exported by /Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn/dist/acorn.mjs?commonjs-proxy, imported by ../../../../../node_modules/acorn-jsx/index.js
    at error (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
    at Module.error (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:12429:16)
    at Module.traceVariable (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:12788:29)
    at ModuleScope.findVariable (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:11440:39)
    at FunctionScope.findVariable (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
    at ChildScope.findVariable (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
    at FunctionScope.findVariable (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
    at ChildScope.findVariable (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
    at Identifier.bind (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:7439:40)
    at CallExpression.bind (file:///Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/rollup/dist/es/shared/rollup.js:5265:73) {
  code: 'MISSING_EXPORT',
  url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module',
  id: '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-jsx/index.js',
  pos: 375,
  loc: {
    column: 7,
    file: '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-jsx/index.js',
    line: 6
  },
  frame: '4: import require$$0 from "\\u0000./xhtml?commonjs-proxy";\n' +
    '5: import "\\u0000acorn?commonjs-require";\n' +
    '6: import require$$1 from "\\u0000acorn?commonjs-proxy";\n' +
    '          ^\n' +
    '7: \n' +
    '8: (function (module) {',
  watchFiles: [
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/.greenwood/_artists.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/.greenwood/_index.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/.greenwood/_post.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/.greenwood/_users.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/src/pages/post.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/src/pages/users.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/src/pages/index.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/src/pages/artists.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/test/cases/serve.default.ssr/src/components/card.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/packages/cli/src/lib/execute-route-module.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/wc-compiler/src/wcc.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/wc-compiler/src/jsx-loader.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/wc-compiler/src/dom-shim.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-walk/dist/walk.mjs',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn/dist/acorn.mjs',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/escodegen.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/index.js',
    '\x00commonjsHelpers.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/escodegen.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/index.js?commonjs-exports',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-jsx/index.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-jsx/index.js?commonjs-module',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/source-map.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/source-map.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/serializer/index.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/serializer/index.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/parser/index.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/parser/index.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/source-map.js?commonjs-exports',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/estraverse/estraverse.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/estraverse/estraverse.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/utils.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/utils.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-jsx/xhtml.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn-jsx/xhtml.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/estraverse/estraverse.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/acorn/dist/acorn.mjs?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/utils.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/parser/formatting-element-list.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-map-generator.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/parser/formatting-element-list.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-map-consumer.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/parser/open-element-stack.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-map-generator.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/parser/open-element-stack.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-map-consumer.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/tree-adapters/default.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/tree-adapters/default.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/utils/merge-options.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/utils/mixin.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/utils/merge-options.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/doctype.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/doctype.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/html.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/html.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/error-codes.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/foreign-content.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-node.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/unicode.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-node.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/unicode.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/error-codes.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/utils/mixin.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/foreign-content.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/extensions/location-info/parser-mixin.js',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/extensions/error-reporting/parser-mixin.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/extensions/error-reporting/parser-mixin.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/extensions/location-info/parser-mixin.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/tokenizer/index.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/tokenizer/index.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/tree-adapters/default.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/doctype.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/html.js?commonjs-exports',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/ast.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/code.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/keyword.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/ast.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/keyword.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/code.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-map-generator.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-map-consumer.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/unicode.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/common/foreign-content.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/source-node.js?commonjs-exports',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/ast.js?commonjs-module',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/keyword.js?commonjs-module',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/esutils/lib/code.js?commonjs-module',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/util.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/util.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/base64-vlq.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/base64-vlq.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/array-set.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/array-set.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/mapping-list.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/mapping-list.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/binary-search.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/binary-search.js?commonjs-proxy',
    '/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/quick-sort.js',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/escodegen/node_modules/source-map/lib/quick-sort.js?commonjs-proxy',
    '\x00/Users/owenbuckley/Workspace/project-evergreen/greenwood/node_modules/parse5/lib/tokenizer/preprocessor.js?commonjs-proxy',
    ... 24 more items
  ]
}
  

Details

Here are some related links, but the work has stalled out so I think we will need to fork our own version.