Skip to content

Require using AMD broken in 10.0.0 #2505

@jlchereau

Description

@jlchereau

Loading via SystemJS in AMD used to work with v9.18.1. Broken in v10:

system.js:4 Uncaught (in promise) ReferenceError: hljs is not defined
    at eval (highlight.js:1566)
    at eval (highlight.js:6322)
    at eval (<anonymous>)
    at Qe (system.js:4)
    at system.js:4
    at async Promise.all (:63342/Kidoju.Widgets/src/js/widgets/index 10)

hljs is undefined when calling L1566

hljs.registerLanguage('apache', function () {
   ...
}());

In System.config.js, I have:

packages: {
    'src/js': {
        defaultExtension: 'js',
        meta: {
           '*.js': {
                babelOptions: {
                    es2015: false,
                    stage2: false,
                    stage3: false,
                },
                format: 'amd',
            },
            '*.es6': {
                format: 'esm',
            },
            '*.jsx': {
                format: 'esm',
            },
            '*.mjs': {
                format: 'esm',
            },
         },
      },
 },

A workaround for now is to add an exception in meta:

 'vendor/highlight/highlight.js': {
      // Note: AMD broken as of v10
      format: 'global',
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp welcomeCould use help from communitypackage/buildIssues relating to npm or packaging

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions